Answer the question
In order to leave comments, you need to log in
How to debug react.js with .jsx file formats in PHPStorm/WebStorm/IntelliJ IDEA?
Modern front-end development methods require js files to be all concatenated and minified. But the development process requires that everything be spread out in different files and folders. Therefore, you have to cocatenate and minify js files for production with a gallop (or similar means). But the issue of debugging remains.
If debugging for regular js files in PHPStorm/WebStorm/IntelliJ IDEA is clear to me, then there is a problem with debugging React .jsx files.
At the moment, I have made a Galpov assembly
var gulp = require('gulp');
var sourcemaps = require('gulp-sourcemaps');
var react = require('gulp-react');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
gulp.task('react', function(){
return gulp.src('www/js/reactjs/*.jsx')
.pipe(sourcemaps.init())
.pipe(react())
.pipe(concat('main.js'))
.pipe(sourcemaps.write('../maps'))
.pipe(gulp.dest('www/js/'));
});
Answer the question
In order to leave comments, you need to log in
I got the solution thanks to Browserify.
In gulpfile.js we write the following:
var gulp = require('gulp');
var browserify = require('browserify');
var reactify = require('reactify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var sourcemaps = require('gulp-sourcemaps');
var uglify = require('gulp-uglify');
gulp.task('react', function(){
return browserify('./www/js/react/app.jsx', { debug: true })
.transform(reactify)
.bundle()
.pipe(source('main.min.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(uglify())
.pipe(sourcemaps.write('../maps'))
.pipe(gulp.dest('./www/js/'));
});
For example, you can use Browserify or Webpack for assembly , which is more preferable for react projects, as it supports hot replacement of updated modules and of course both of them support sourcemap creation
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question