Monday, 22 May 2017

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?



via Tiaw

No comments:

Post a Comment