Bundle files into the output templates, styles and scripts
npm i trucks-transform-bundle --save-dev
For the command line interface see trucks-cli.
Use the bundle
key to configure this transform:
const trucks = require('trucks');
trucks(
{
files: ['components.html'],
transforms: ['bundle'],
conf: {
transforms: {
bundle: {
css: ['styles.css'],
js: ['app.js']
}
}
}
}, (err, res) => {
if(err) {
throw err;
}
console.log(res);
}
);
public bundle(state, conf)
Add input files to the output templates, styles and scripts.
The default behaviour will prepend input files.
Use the css
, html
and js
lists to prepend files to the
corresponding output file. You may also use a more explicit notation
with the before
and after
options to control whether bundled
files are appended or prepended.
Returns map of visitor functions.
-
state
Object compiler state. -
conf
Object transform plugin configuration.
-
before
Object map of files to prepend. -
after
Object map of files to append. -
css
Array files to bundle with the stylesheet. -
html
Array files to bundle with the templates. -
js
Array files to bundle with the javascript.
MIT
Created by mkdoc on July 28, 2016