我正在尝试使用Browserify和Uglify缩小我main.js
bundle.js
,这样做效果很好:
browserify assets/js/main.js | uglifyjs > assets/bundle.js
但现在我在ES6中有依赖,我需要使用Babelify但是要使用Uglify和Babelify吗?
这样做不起作用:
browserify assets/js/main.js | uglifyjs > assets/bundle.js -t [ babelify --presets [ es2015 react ] ]
我收到错误:
ERROR: ENOENT: no such file or directory, open 'babelify'
at Error (native)
at Object.fs.openSync (fs.js:641:18)
at Object.fs.readFileSync (fs.js:509:33)
at read_file (/usr/local/lib/node_modules/uglify-js/bin/uglifyjs:303:19)
at /usr/local/lib/node_modules/uglify-js/bin/uglifyjs:151:37
at Array.forEach (native)
at Object.<anonymous> (/usr/local/lib/node_modules/uglify-js/bin/uglifyjs:150:31)
at Module._compile (module.js:570:32)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
我该如何解决?
答案 0 :(得分:1)
尝试这个怎么样?
browserify assets/js/main.js -t [ babelify --presets [ es2015 react ] ] | uglifyjs > assets/bundle.js