3.0.0 • Published 9 years ago
underscore-loader v3.0.0
underscore-loader
Webpack loader for pre-compiled Underscore/Lodash templates with HTML minification
- template is compliled with lodash.template
- template are minified by html-minifier
Installation
$ npm install --save underscore-loader lodash.escapeImportant!!1
For webpack 1.x.x use version 2.0.0
Options (defaults)
Webpack (2.x.x) config
{
// ...
module: {
rules: [
{
test: /\.tpl$/,
loader: 'underscore-loader',
options: {
engine: 'var _ = { escape: require(\'lodash.escape\') };\n',
minifierOptions: { collapseInlineTagWhitespace: true }
}
}
]
}
// ..
}engine
- for full
lodashset it tovar _ = require(\'lodash\'); - for full
underscoreset it tovar _ = require(\'underscore\'); lodash.escapeis default, change it tolodash,underscoreorsome-other-engine
minify
- default is
true - uses html-minifier
minifierOptions
- minify options - html-minifier options
originalSource
- append original html in comment
templateOptions
- template options - lodash documentation
Setting template engine
- set underscore/lodash/other-module dependency in
package.json - if you don't use any logic in your templates, you can pass empty string (
engine: '')