I constantly find myself using the same Browserify plug-ins and transforms on every project, and I always end up writing pretty much the same Gulp script over and over again. Simplifyify is the solution to that problem.
Usage: simplifyify [options] <source-files...>Options: -b, --bundle Create a non-minified bundle (*.js) for each source file. This is the default if no other output option is set. -m, --minify Create a minified bundle (*.min.js) for each source file. -c, --coverage Create a bundle with code-coverage instrumentation (*.coverage.js) for each source file. -d, --debug Create a source map (*.js.map) for each bundle -w, --watch Watch source file(s) and rebuild the bundle(s) automatically -o, --outfile <filespec> The output file or directory. May include a filename pattern (e.g. "*.bundle.js") -x, --exclude <filespec> File path or glob pattern to exclude. Don't forget to put quotes around glob patterns -s, --standalone <name> Export as a named UMD bundle (e.g. "my.cool.module") May include a wildcard (e.g. "MyLib.*")Arguments: <source-files...> One or more file paths and/or glob patterns. Don't forget to put quotes around glob patterns. A separate Browserify bundle will be created
Examples
One entry file --> one output file
In the simplest usage, you can use Simplifyify to bundle all of your code into a single file:
By default, the output file is at the same path as the entry file, but with a .bundle.js extension. You can customize this using the --outfile argument:
Simplifyify can output multiple bundles of your code in a single command. Let's say you want to create an unminified bundle for development (with a source map), a minified bundle for production (with a source map), and a test bundle (with code-coverage instrumentation) for testing:
Multiple entry files --> multiple output files for each
In many applications, it doesn't make sense for all of your code to be bundled into one huge file. Maybe you want to create separate bundles for each folder, or for each component or section of your app. Simplifyify makes this easy. It will create separate bundles for each entry file that you specify. For example:
Specifying each entry file can quickly become cumbersome though. That's where globs come in. You can specify one or more globs, and Simplifyify will create a separate bundle for each file that matches the glob pattern. For example:
TIP: Don't forget to put quotes around your glob patterns! Otherwise, some shells (e.g. Bash) will try to expand them themselves, which may or may not work
Browserify Transforms
Simplifyify honors the browserify.transform field in your package.json file. For example, the following configuration uses Babelify to transform your ES6 code to ES5:
You can also specify options for your transforms. The exact options depend on the transform you're using. Here's an example that configures Babelify and also modifies Simplifyify's default config for uglifyify:
The same technique described above for Browserify transforms also works for Browserify plugins. Just add a browserify.plugins field to your package.json file. For example, the following configuration configures TSify to transpile your TypeScript code, and browserify-banner to add a banner comment to the top of your output file(s).
Clone this repo git clone https://github.com/JS-DevTools/simplifyify.git
Install dependencies npm install
Run the tests npm test
License
Simplifyify is 100% free and open-source, under the MIT license. Use it however you want.
This package is Treeware. If you use it in production, then we ask that you buy the world a tree to thank us for our work. By contributing to the Treeware forest you’ll be creating employment for local families and restoring wildlife habitats.
Big Thanks To
Thanks to these awesome companies for their support of Open Source developers ❤
jamesmessinger
james.messinger@gmail.com
--debug creates external source-maps (.map) using exorcist