build Ractive.js components using the library behind the ractive bin
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore update README example to work with webpack2 Jun 14, 2017 1.0.2 Sep 29, 2017 update README example to work with webpack2 Jun 14, 2017
index.js properly load external files from non-cwd sources Sep 29, 2017
package.json 1.0.2 Sep 29, 2017


This webpack loader allows you to write Ractive.js components and have them available pre-compiled for the rest of your webpack build.


npm install --save-dev ractive-bin-loader


Merge this into your webpack.config.js:

module: {
  loaders: [
      // you can scope this by directory or using another extension
      // using .ractive.html for your components gives you good
      // syntax highlighting with most editors
      test: /\.ractive\.html$/,
      loaders: 'ractive-bin-loader'

Then you can write components like this:

<!-- you can also use a link tag with an external stylesheet -->
  /* styles are concatenated, stringified, and injected wherever $CSS is found in the template */
  .my-ractive-component {
    margin: 1em;
    background-color: #eee;
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0,12), 0 1px 2px rgba(0, 0, 0, 0.24);
    padding: 1em;

<script type="text/ractive" id="myPartial">
    Partials can be added as scripts with a type of text/ractive or text/html.
    They can also include a src attribute to be loaded from an external file.

<!-- any html is gathered up to be parsed and injected wherever $TEMPLATE is found in the script -->
<div class="my-ractive-component">
  <button on-click="['go']">Go</button>

  // any non-partial scripts are concatenated
  // ES module syntax is _strongly_ recommended
  import Ractive from 'ractive';

  export default Ractive.extend({
    template: $TEMPLATE,
    css: $CSS,
    on: {
      go() { alert('Hello, from my webpacked Ractive.js component!'); }

  // external scripts can also be loaded and concatenated with any inline scripts
  // by supplying a relative src attribute