webpack2-ejs-render-loader
v1.2.0
Published
EJS webpack 2 render loader (without frontend dependencies)
Downloads
4
Readme
webpack2-ejs-render-loader for webpack
EJS render loader for webpack. Uses ejs function to render templates. Use this loader in combination with raw-loader.
This is the initial and very simple version. Much more changes are needed and anyone is welcome to make further changes.
Installation
npm install webpack2-ejs-render-loader
Usage
module: {
rules: [{
test: /\.ejs$/,
use: [{
loader: 'webpack2-ejs-render-loader',
options: { data: { href: '/my/about', Age: '20' } }
},
{
loader: 'raw-loader'
}
]
}]
}
test.ejs
<div>
<a href="<%= data.href %>">Name</a>
</div>
Webpack Output bundle:
module.exports = "<div>\n <a href=\"/my/about\">Name</a>\n</div>\n"
Look at the example provided in the folder - example. Navigate to the example folder and run "npm run build", the webpack bundle will be created in example/dist/main.bundle.js.
License
MIT (http://www.opensource.org/licenses/mit-license.php)