tilt-assets
Tiny asset pipeline
Install
npm i tilt-assets -S
Usage
var pipeline = ; var server = http; server;
Options
- dirs Glob directory patters (must end with a "/". Default: app/assets/)
- baseURL Base URL removed from the incoming request URL (Default: '/assets/')
Browserify
Browserify is the default handler for .js
files.
You can further configure browserify transforms with a package.json
browserify.transform
field.
For instance, to configure browserify to compile into ES6, make sure you've installed the babelify transform and babel-preset-es2015.
"browserify":
Note: Presets and plugins need to be installed as separate modules.
Other browserify
options can
be configured using browserify
field.
For instance, to add a source map to the end of the bundle:
"browserify":
PostCSS
PostCSS is the default handler for .css
files.
You can configure PostCSS plugins
with a package.json postcss.use
field.
"postcss":
Plugin configuratons can be defined using plugin names as keys.
"postcss":
Note: PostCSS plugins need to be installed as separate modules. For the above example to work, you'd need to install autoprefixer and cssnano.
Additionnaly, other postcss configuration
options
can be specified using package.json postcss
field.
For instance, to add a source map to the end of the file:
"postcss":
API
Asset
new Asset.
var instance = ;assert;assert;assert;
Compiles JS into ES6.
var stream = fs;thisassets;stream;
Compiles CSS using postcss / autoprefixer.
var stream = fs;thisassets;stream;
HTTP handler
Renders foo.
;
Renders js.
// Check basic output // Check ES6 compilation ;
Renders css.
// Check basic output // Check autoprefixer output ;