Compile/minify static site for production (with sourcemaps), auto-compiles files like
app.coffee -> app.js.
swig. To use any of these you must do
npm install x as needed (where
x is the name of the lib), baconize does not install them by default.
var baconize = ;var source = '/path/to/input/dir';var target = '/path/to/output/dir';;
How it works:
- Baconize will walk your source directory and process each file in
- If it can compile a file then it will compile it and output it to the target directory (with source map).
- If it can't compile the file then it will simply copy it to the target.
For example, if you have a coffeescript file in
/path/to/input/dir/my-app/scripts/index.coffee then it will output the compiled file as
/path/to/output/dir/my-app/scripts/index.js, and the sourcemap as
This library is designed for use alongside pingy-in-the-middle.
compile (Boolean, default = true): should baconize try to compile files where possible?
sourcemaps (Boolean, default = true): should baconize copy corresponding sourcemaps and source files for the minified/compiled files?
blacklist (Array): filter to blacklist files from being compiled or minifed. They will still be copied (without compilation/minifiction) unless they are negated using the
directoryFilteroptions below. This option is useful for vendor directories (like 'bower_components') which already include the compiled versions of files. See Filters for more.
fileFilter (Array): filter to include/exclude files to be copied to target. See Filters for more.
directoryFilter (Array): filter to include/exclude directories to be copied to target, rules are applied to sub-directories also. Useful for directories like '.git'. See Filters for more.
depth (Number): depth at which to stop recursing even if more subdirectories are found.
exclusions (Object): Instead of
directoryFilteryou can use the new exclusions api, this is undocumented for the moment.
Filters take an array of glob strings.
directoryFilter can be a whitelist or blacklist, by default they are whitelist but add the
! character before entries to turn them into a blacklist instead:
compileBlacklist: [ 'bower_components/**' ]copies the raw 'bower_components' directory instead of compiling files within the directory.
directoryFilter: [ '!.git', '!node_modules' ]includes all directories except '.git' and 'node_modules'.
See minimatch for some examples of glob strings.
You can listen to
compile-finised events emitted by baconize.
var bacon = ;bacon;bacon;bacon;
Aborting while in progress
You can abort baconize while it's in progress. If you do this then the promise will reject and the output directory will be removed.
var bacon = ;// abort baconize while in progress;bacon
Try it out
The easiest way to try this out is to
clone the repo,
cd into it and do:
npm installnpm run example
This will compile a basic demo site to