I am looking for a good way to do minification with browserify.
I am developing a react application trying to keep the build setup as simple as possible.
I am using browserify
, babelify
and watchify
.
I do not want to use a task runner like grunt
or gulp
but just npm
in order to keep the setup as simple as possible.
I would like to use the same parameters for browserify (production build) and watchify (during development). The compiled js during development should be exactly the same as in the production build (ie I want minification during development as well. And I want the strongest minification possible with browserify. I know there are other module loaders like rollup or systemjs that achieve even smaller outputs but that's not what I am interested in.
My current watch
command looks like this:
watchify src/main.js -t babelify -t envify -o build/bundle.js -v
the corresponding build command looks like this:
browserify src/main.js -t babelify -t envify -o build/bundle.js -v
Note that all the parameters look the same. That's how I want to to be in order to keep the commands in sync in the future.
Now my question is how to add uglification/minification.
I tried adding uglifyify like this: -g [ uglifyify --no-sourcemap ]
but there are still a lot of line breaks in the output so I guess it's not fully minified.
I also tried removing the -o
parameter and piping the output throught uglifyjs as described here. This produces a smaller output but it does not work for the watchify
command.