a browserify plugin that runs various optimizations, so you don't have to install them all manually.
npm install --save-dev tinyify
browserify -p tinyify app.js- unassertify - Remove
assert()calls - envify - Replace environment variables—by default, replaces
NODE_ENVwith"production" - uglifyify - Remove dead code from modules
- common-shakeify - Remove unused exports from modules
- browser-pack-flat - Output a "flat" bundle, with all modules in a single scope
- minify-stream - Uglify the final bundle
Options can be provided on the command line using subarg syntax, or in a separate options object using the browserify API.
Supply custom environment variables for envify.
b.plugin('tinyify', {
env: {
PUBLIC_PATH: 'https://mywebsite.surge.sh/'
}
})This option is only available in the API. On the CLI, you can define environment variables beforehand instead:
PUBLIC_PATH=https://mywebsite.surge.sh browserify app.js -p tinyifyDisable browser-pack-flat. This is useful if you want to generate a browser-pack style bundle, like required by disc for example.
browserify app.js -p [ tinyify --no-flat ]b.plugin('tinyify', { flat: false })