browserify-shim: { 'foo': 'global:Foo' }
browserify-shim: { 'mod': { depends: "foo" }}
Hi, I am working on a pretty simple project using React with babel and browserify. I am struggling to get proper minification/uglification working.
I already tried using minifyify and uglifyify. But there are still a lot of line breaks in the final file and overall the result seems still to large.(~300-400kb)
When using minifyify and then apply to uglifyjs2 to the output the file size goes down to ~200kb.
But it feels pretty redundant and does not work with watchify.
So I guess my question is: When using babel/browserify/watchify via cli, what's the best and simplest way to do minification?
NODE_ENV=production browserify src/main.js -t babelify -g envify -v -p bundle-collapser/plugin -p [minifyify --no-map --uglify [ --compress [ --dead_code ] --mangle ] ] | uglifyjs -m -e -c dead_code,screw-ie8,warnings=false > build/bundle.js
But passing all the uglify options twice feels wrong.
I would like it to look more like:
watchify src/main.js -t babelify -g envify -p uglify -o build/bundle.js -v
gulp.task('js:compile', function() {
return browserify([ deployDir + '/js/pages/newModelVisualization.js'
], { debug: true })
.transform(babelify,{presets: [__dirname + "/node_modules/babel-preset-es2015-nostrict"]})
.bundle()
.pipe(source('modelerWizardFlow-min.js'))
.pipe(gulp.dest('.'))
})
events.js:160
throw er; // Unhandled 'error' event
^
Error: Cannot find module 'underscore' from '/home/velvet/tf/src-docroot/js/lib'
at /home/velvet/tf/frontend/node_modules/resolve/lib/async.js:46:17
at process (/home/velvet/tf/frontend/node_modules/resolve/lib/async.js:173:43)
at ondir (/home/velvet/tf/frontend/node_modules/resolve/lib/async.js:188:17)
at load (/home/velvet/tf/frontend/node_modules/resolve/lib/async.js:69:43)
at onex (/home/velvet/tf/frontend/node_modules/resolve/lib/async.js:92:31)
at /home/velvet/tf/frontend/node_modules/resolve/lib/async.js:22:47
at FSReqWrap.oncomplete (fs.js:123:15)
import { _ } from './lib/underscore.js'
require('my-project')
to /local/path/to/my-project
ERROR: Cannot find module './modules/es6.string.fontsize'
)
browserify is still awesome.
I was making a card for my dad for fathers day, in code of course, & since I spent a fair bit the time on the card, I didn't have any to waste on a build system.
browserify -t [ browserify-css --autoInject=true ] --entry js/main.js -o index.browserified.js
index file with all the codes, full of the win.