Package Exports
- @moomfe/hu-template-minifier
- @moomfe/hu-template-minifier/rollup
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@moomfe/hu-template-minifier) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Hu-Template-Minifier
该类库将使用了 模板字符串 - 标签 ( Template literals ) 功能实现模板定义的类库中的 HTML 代码进行压缩.
Overview
html`
<div title=${ 'title' } class="a ${ b } c ${ d }">
<div>...</div>
${
html`
<div>
<span>Something ...</span>
</div>
`
}
<div>...</div>
</div>
`
// ↓↓↓
html`<div title=${ 'title' } class="a ${ b } c ${ d }"> <div>...</div> ${
html`<div> <span>Something ...</span> </div>`
} <div>...</div> </div>`
Installation
npm install @moomfe/hu-template-minifier
Usage
// 使用 minifier 的 rollup 插件
const minifier = require('@moomfe/hu-template-minifier/rollup');
rollup({
plugins: [
minifier(/* options */)
]
});
Plugin Options
{
// 需要进行压缩的文件后缀
extensions: [ '.js' ], // 默认值
// 可包含多个
extensions: [ '.js', '.ts' ],
// 需要包含的文件
include: undefined, // 默认值 ( 包含全部 )
// 普通匹配
include: 'index.js',
// 使用 minimatch 格式进行匹配
include: 'components/*/index.js',
include: 'components/**/index.js',
// 使用正则进行匹配
include: /api\.js/,
// 使用支持的格式组成数组进行匹配
include: [
'components/*/index.js',
/api\.js/
],
// 需要从已包含的文件中排除的文件
// 使用的格式与 include 选项一致, 不再进行举例
exclude: undefined, // 默认值
// 保留一个空格
conservativeCollapse: true,
// 移除注释
removeComments: false
}
Supports
Transplant From
License
Hu-Template-Minifier is licensed under a MIT License.