Use Browserify and Uglify with Babelify

i'm trying to minify my main.js on bundle.js using Browserify and Uglify it's working well doing like this:

browserify assets/js/main.js | uglifyjs > assets/bundle.js

but now i have a dependency made in ES6 and i need to use Babelify but to use Uglify and Babelify?

doing this doesn't work:

browserify assets/js/main.js | uglifyjs > assets/bundle.js -t [ babelify --presets [ es2015 react ] ]

i get error :

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)

How can i fix it?


试试这个怎么样?

browserify assets/js/main.js -t [ babelify --presets [ es2015 react ] ] | uglifyjs > assets/bundle.js 
链接地址: http://www.djcxy.com/p/5646.html

上一篇: 无法使用nexmo或thilio发送短信

下一篇: 使用Browserify和Uglify与Babelify