recompile-swig-loader for webpack
Exports a Swig template as a compiled template for webpack.
Install this into your project:
$ npm install --save precompile-swig-loader
Make all your .html
files compile down to Swig templates by
modifying your webpack.config.js
file:
/* webpack.config.js */
module.exports = {
module: {
loaders: [
{ test: /\.html$/, loader: 'precompile-swig' }
]
},
...
};
Then use your Swig templates via swig.run
:
var result = swig.run(require('./greet.html'), {greeting: "Hello World!"});
You can also use it without modifying your config. Just explicitly call it on
your require()
call via a prefix:
var result = swig.run(require('precompile-swig!./greet.html'), {greeting: "Hello World!"});
precompile-swig-loader © 2015+, Mark Johnson. Released under the MIT License.
Authored and maintained by Mark Johnson.