DEPRECATED
This module is for Apostrophe 0.5 only, not the 2.x stable release.
Even with 0.5, it requires the server to run browserify and babel, which slows things down needlessly. Just create your own gulp workflow in development which generates an output file that is pushed as an asset to Apostrophe in the usual way.
Apostrophe Browserify
This Apostrophe 2 module enables you to bundle your frontend code using browserify
while taking advantage of automatic minification and Apostrophe's asset pipeline.
When using the development
option watchify
will run, recompiling your assets any time they are saved.
Installation
To use it, run npm install apostrophe-browserify --save
and add it to your app.js
configuration:
{
...
'apostrophe-browserify': {
files: [ './public/js/modules/_site.js' ]
}
...
}
Configuration
Apostrophe will save your bundled file to the public/js/
directory. By default it creates _site-compiled.js
, however the filename can be configured using the outputFile
option.
You specify your input files using the files
option. You may specify more than one. Your input files may use the require
statement, much as they can in node apps, as described in the browserify
documentation.
{
'apostrophe-browserify': {
files: [ './public/js/modules/_site.js' ],
outputFile: '_site-compiled.js',
development: false,
verbose: true,
notifications: false,
es2015: true,
react: true,
brfs: true,
browserifyOptions: {
}
}
}
For production use
-
Make sure you add public/js/_site-compiled.js
to your .gitignore
and deployment/rsync_exclude.txt
files.
-
When minify
is true, which it should be for all production Apostrophe sites, the output file will not be recompiled, even on startup, unless it does not exist yet. Together with the apostrophe:generation
task, this prevents race conditions in a multicore Apostrophe production environment.
Changelog
0.5.8
: added native notifications when build fails, improved error logging. Updated styling of console logs to be a little clearer.
0.5.6
: added source mapping and timestamp logging on recompile when in development
mode.
0.5.5
: no need to manually add the output file to your assets. Behaves properly in a multicore environment as long as minify
is true. Documentation updated. The basedir
option has been removed, as this module is currently only intended for project-level code, but more thought will be given to how this module could be used in conjunction with module-level code in the future.