Compile Ractive.js components with gobble.
First, you need to have gobble installed - see the gobble readme for details. Then,
npm i -D gobble-ractive
gobblefile.js
var gobble = require( 'gobble' );
module.exports = gobble( 'ractive_components' ).map( 'ractive', { type: 'amd' });
Supported output types are amd
, cjs
(i.e. node.js modules) or es6
. If the second argument is omitted, amd
is the default type.
Example with gobble-browserify
Given this directory structure:
./gobblefile.js
./src/component/some-component.html
./src/js/app.js
Then, the gobblefile.js should include:
gobble( 'src' ).map( 'ractive', { type: 'cjs' } ).transform( 'browserify', {
entries: './js/app.js', // can be string or array
dest: 'bundle.js'
}),
And the javascript/app.js can include:
var SomeComponent = require('../component/some-component');
var thing = new SomeComponent({
el: '#id-of-the-div-where-this-component-should-be-displayed'
});
Note that you need to also have Ractive itself installed so that Browserify can find it - npm install ractive
.
MIT. Copyright 2014 Rich Harris