First ensure, that you're ColdBox Elixir version is up to date. It should be at least version 2 or newer.
npm install coldBox-elixir-browserify --save-dev
// Gulpfile.js
var elixir = require( "coldBox-elixir" );
elixir( function( mix ) {
mix.browserify( "main.js" );
// mix.browserify(srcPath, outputPath, srcBaseDir, browserifyOptions)
} );
This will compile, by default, resources/assets/js/main.js
to includes/js/main.js
. Should you require a different source directory, either provide an optional path as the third argument to mix.browserify
, or begin your path with ./
. This will instruct Elixir to ignore any default base directories.
elixir( function( mix ) {
mix.browserify( "./app/assets/js/main.js" );
} );
The same is true for the output path.
elixir( function( mix ) {
mix.browserify( "./app/assets/js/main.js", "public/build/bundle.js" );
} );
The fourth argument to the browserify
method is an options
object that will be passed through to the browserify task.
elixir( function( mix ){
mix.browserify( 'main.js', 'includes/javascripts/main.js', 'public/js', {} );
} );
While Browserify ships with the Partialify and Babelify transformers, you're free to install and add more if you wish by doing 2 simple steps:
- Install the transformer
npm install aliasify --save-dev
- update your
Gulpfile.js
by pushing the new transformer configuration via theelixir.config.js.browserify.transformers
array:
elixir.config.js.browserify.transformers.push( {
name : 'aliasify',
options : {}
} );
elixir( function( mix ){
mix.browserify( 'main.js' );
} );
Project tracking for this project can be found at the Ortus Solutions Jira. Please log all bugs, improvements, and features there.
Pull requests are welcome and encouraged. Please check on the Jira page before starting any large amount of work so your time isn't wasted.
Brad Wood (@bdw429s) has a great guide on submitting pull requests. If you are unsure where to go, in need of help, or have a question, come ask in the #box-products channel on the CFML Slack.