1.1.0 • Published 6 years ago

template-minify-loader v1.1.0

Weekly downloads
2
License
ISC
Repository
github
Last release
6 years ago

template-minify-loader

Lodash template loader for webpack. Besides standard template creating, removes extra white spaces.

Peer dependency

lodash or lodash.template must be installed.

Installation

npm i template-minify-loader

Usage

module.exports = {
  //...
  module: {
    loaders: [
      {
        test: /\.tpl$/,
        use: [{
          loader:'template-minify-loader',
          options: {
            /* By default, loader will only compile the template.
             * If `execute` is set to a truthy value, templates will be called with it.
             * The results of this call will be returned instead of the template.
             */
            execute: false            
          }
        }]
      }
    ]
  },
};

Using compiled template

<!-- template.tpl -->
'<div class="<%= someClass %>"><% %></div>'
const template = require('./template.tpl');
const result = template({name: 'some-class'});

/* Prints '<div class="some-class"></div>' */
console.log(result);