2.0.1 • Published 4 years ago

babel-plugin-html-tag v2.0.1

Weekly downloads
20
License
MIT
Repository
github
Last release
4 years ago

babel-plugin-html-tag

Statically evaluates and minifies tagged html`<..>` template literals into strings

npm tested with jest codecov node

What it does:

Minifies tagged template literals (by default using html tag) via html-minifier then removes the tag:

In:

const a = html`<p class="zoom center justify">
  This is paragraph with ${b} subsitutions at several lines: ${1 + 2}
</p>`;

const z = html`<table class="center">
  <tr class="left">
    <td>HTML without substitutions</td>
  </tr>
</table>`;

Out:

const a = `<p class="zoom center justify">This is paragraph with ${b} subsitutions at several lines: ${
  1 + 2
}</p>`;

// becomes static one line string if there is no substitutions
const z =
  '<table class="center"><tr class="left"><td>HTML without substitutions</td></tr></table>';

Tip

Try it with Visual Studio Code bierner.lit-html plugin for beautiful syntax highlight and HTML autocomplete inside tagged HTML string.

Credits

Inspired by babel-plugin-template-html-minifier and babel-plugin-graphql-tag

2.0.1

4 years ago

2.0.0

4 years ago

1.4.1

4 years ago

1.4.0

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.0

5 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago