Webpack loader that minifies javascript files that contain lit-html template literals
|
|
4 years ago | |
|---|---|---|
| test | 4 years ago | |
| .gitignore | 4 years ago | |
| .npmignore | 4 years ago | |
| .nvmrc | 4 years ago | |
| README.md | 4 years ago | |
| index.js | 4 years ago | |
| minifyTemplate.js | 4 years ago | |
| package-lock.json | 4 years ago | |
| package.json | 4 years ago |
Webpack loader that minifies javascript files that contain template literals
This loader takes .js files with html and css literals and minifies them with html-minifier and clean-css.
// converts this:
export default
html`<div>
Awesome Template
</div>`;
// to this:
export default html`<div>Awesome Template</div>`;
$ npm install -D minify-lit-elt-template-literal-loader
Add this loader to your webpack rules BEFORE running through a transpiler like babel.
Remember, webpack runs loaders right-to-left, and bottom-to-top:
config.module.rules = [
{
test: /\.js$/,
loader: 'babel-loader'
},
{
test: /\.template\.js$/,
loader: 'minify-lit-elt-template-literal-loader',
options: {
caseSensitive: true,
collapseWhitespace: true
}
}
{
test: /\.tsx?$/,
use: 'ts-loader',
exclude: /node_modules/,
}
]
The options object is a pass-through to the html-minifier options. Go to html-minifier's github page to learn more.