Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/browserify/tinyify
a browserify plugin that runs various optimizations, so you don't have to install them all manually. makes your bundles tiny!
https://github.com/browserify/tinyify
browserify browserify-plugin minify optimize tree-shaking uglify
Last synced: 5 days ago
JSON representation
a browserify plugin that runs various optimizations, so you don't have to install them all manually. makes your bundles tiny!
- Host: GitHub
- URL: https://github.com/browserify/tinyify
- Owner: browserify
- License: other
- Created: 2017-10-10T17:18:55.000Z (about 7 years ago)
- Default Branch: default
- Last Pushed: 2023-04-19T05:07:24.000Z (over 1 year ago)
- Last Synced: 2024-05-15T13:26:06.321Z (6 months ago)
- Topics: browserify, browserify-plugin, minify, optimize, tree-shaking, uglify
- Language: JavaScript
- Homepage:
- Size: 75.2 KB
- Stars: 409
- Watchers: 7
- Forks: 40
- Open Issues: 8
-
Metadata Files:
- Readme: readme.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# tinyify
a browserify plugin that runs various optimizations, so you don't have to install them all manually.
[![npm][npm-image]][npm-url]
[![travis][travis-image]][travis-url]
[![standard][standard-image]][standard-url][npm-image]: https://img.shields.io/npm/v/tinyify.svg?style=flat-square
[npm-url]: https://www.npmjs.com/package/tinyify
[travis-image]: https://img.shields.io/travis/browserify/tinyify.svg?style=flat-square
[travis-url]: https://travis-ci.org/browserify/tinyify
[standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square
[standard-url]: http://npm.im/standard```bash
npm install --save-dev tinyifybrowserify -p tinyify app.js
```## Included
- [unassertify][] - Remove `assert()` calls
- [@browserify/envify][] - Replace environment variables—by default, replaces `NODE_ENV` with `"production"`
- [@browserify/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
- [bundle-collapser][] - When using the `--no-flat` option, bundle-collapser replaces file paths in `require()` calls with short module IDs
- [minify-stream][] - Uglify the final bundle[browser-pack-flat][] and [bundle-collapser][] are both not used if the `--full-paths` option is passed to Browserify.
This way you can still get all of tinyify's other optimizations when building for [disc][].## Options
Options can be provided on the command line using subarg syntax, or in a separate options object using the browserify API.
### `env: {}`
Supply custom environment variables for [@browserify/envify][].
```js
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:```bash
PUBLIC_PATH=https://mywebsite.surge.sh browserify app.js -p tinyify
```### `--no-flat`, `flat: false`
Disable [browser-pack-flat][].
This enables [bundle-collapser][] instead which will still shrink the output bundle a bit by replacing file paths with short module IDs.```bash
browserify app.js -p [ tinyify --no-flat ]
``````js
b.plugin('tinyify', { flat: false })
```## More options?
If you need further customisation, I recommend installing the tools separately instead:
```bash
npm install --save-dev unassertify @browserify/envify @browserify/uglifyify common-shakeify browser-pack-flat terser
browserify entry.js \
-g unassertify \
-g @browserify/envify \
-g @browserify/uglifyify \
-p common-shakeify \
-p browser-pack-flat/plugin \
| terser -cm \
> output.js
```Or with the Node API:
```js
browserify('entry.js')
.transform('unassertify', { global: true })
.transform('@browserify/envify', { global: true })
.transform('@browserify/uglifyify', { global: true })
.plugin('common-shakeify')
.plugin('browser-pack-flat/plugin')
.bundle()
.pipe(require('minify-stream')({ sourceMap: false }))
.pipe(fs.createWriteStream('./output.js'))
```Alternatively you can fork this repo and publish it on npm under a scope with your modifications.
## License
[Apache-2.0](./LICENSE.md)
[unassertify]: https://github.com/unassert-js/unassertify
[@browserify/envify]: https://github.com/browserify/envify
[@browserify/uglifyify]: https://github.com/browserify/uglifyify
[common-shakeify]: https://github.com/browserify/common-shakeify
[browser-pack-flat]: https://github.com/goto-bus-stop/browser-pack-flat
[bundle-collapser]: https://github.com/substack/bundle-collapser
[minify-stream]: https://github.com/goto-bus-stop/minify-stream
[browser-pack]: https://github.com/browserify/browser-pack
[disc]: https://github.com/hughsk/disc