reactjs - Babelify omit file extension on import -


i writing react application es6 , jsx. below command use browserify .es6 files bundle.js.

$ browserify src/es6/app.es6 -t babelify -o build/js/bundle.js 

when try import component using import menubar './menu', error message:

error: cannot find module './menu' 

the workaround found adding .es6 file name (import menubar './menu.es6'), isn't appealing at.

is there way let browserify or babelify know extensions use when importing modules?

try:

browserify src/es6/app.es6 -t babelify -o build/js/bundle.js \ --extension=.js --extension=.json --extension=.es6 

babelify should handle .es6 default on end.

by way, if can you're better off writing scripts against browserify api rather using cli. in case it'd like:

var   browserify = require('browserify'),   babelify = require('babelify'),   path = require('path'),   fs = require('fs');  browserify('src/es6/app.es6', {   extensions: ['.js', '.json', '.es6'], })   .transform(babelify)   .bundle()   .pipe(fs.createwritestream(path.join(__dirname, 'build/js/bundle.js'))); 

Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -