项目作者: tomek-f

项目描述 :
Underscore/Lodash template loader for webpack
高级语言: JavaScript
项目地址: git://github.com/tomek-f/underscore-loader.git
创建时间: 2016-01-09T10:09:56Z
项目社区:https://github.com/tomek-f/underscore-loader

开源协议:MIT License

下载


underscore-loader

Webpack loader for pre-compiled Underscore/Lodash templates with HTML minification

Installation

  1. $ npm install --save underscore-loader lodash.escape

Important!!1

For webpack 1.x.x use version 2.0.0

Options (defaults)

Webpack (2.x.x) config

  1. {
  2. // ...
  3. module: {
  4. rules: [
  5. {
  6. test: /\.tpl$/,
  7. loader: 'underscore-loader',
  8. options: {
  9. engine: 'var _ = { escape: require(\'lodash.escape\') };\n',
  10. minifierOptions: { collapseInlineTagWhitespace: true }
  11. }
  12. }
  13. ]
  14. }
  15. // ..
  16. }

engine

  • set it to var _ = { escape: require(\'lodash/escape\') };
  • for full lodash set it to var _ = require(\'lodash\');
  • for full underscore set it to var _ = require(\'underscore\');
  • lodash.escape is default, change it to lodash, lodash/escape, underscore or some-other-engine

minify

minifierOptions

originalSource

  • append original html in comment

templateOptions

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: '')

Custom module’s path examples (old README)

View on github.

Changelog

View on github.