node package manager
Orgs are free. Discover, share, and reuse code in your team. Create a free org »

babel-plugin-template-html-minifier

babel-plugin-template-html-minifier

Minify HTML in tagged template strings using html-minifier.

Install

npm install --save-dev babel-plugin-template-html-minifier

Usage

In .babelrc:

{
  "plugins": [
    "template-html-minifier"
  ]
}

With options:

{
  "plugins": [
    ["template-html-minifier", {
      "tags": ["bel"]
    }]
  ]
}

Options

All options are passed through to html-minifier. See the html-minifier docs.

Additional options for the Babel plugin are:

tags

An array of template tag identifier names.

yo`
  <div class="hello">
    Hello World
  </div>
`
multiline`
  This
  is
  not
  html
`

With "tags": ["yo"] becomes:

yo`<div class="hello"> Hello World </div>`
multiline`
  This
  is
  not
  html
`

modules

An array of modules that export a template tag.

import bel from 'bel'
var yo = require('yo-yo')
bel`<div class="hello"> Hello World </div>`
yo`
  <div>
    <p>a</p>
    <p>b</p>
  </div>
`

With "modules": ["bel", "yo-yo"] becomes:

import bel from 'bel';
var yo = require('yo-yo');
bel`<div class=hello>Hello World</div>`;
yo`<div><p>a<p>b</div>`;

License

MIT