Skip to content
This repository has been archived by the owner on Apr 8, 2023. It is now read-only.
/ underscore-loader Public archive

Underscore/Lodash template loader for webpack

License

Notifications You must be signed in to change notification settings

tomek-f/underscore-loader

Repository files navigation

underscore-loader

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

Installation

$ 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

{
  // ...
 module: {
    rules: [
      {
        test: /\.tpl$/,
        loader: 'underscore-loader',
        options: {
          engine: 'var _ = { escape: require(\'lodash.escape\') };\n',
          minifierOptions: { collapseInlineTagWhitespace: true }
        }
      }
    ]
  }
  // ..
}

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.

About

Underscore/Lodash template loader for webpack

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published