我正在使用这里的webpack入门:
https://github.com/AngularClass/angular2-webpack-starter
在 webpack 的配置中,有这样的代码(我自己添加了 minify 选项)。new HtmlWebpackPlugin({ template: 'src/index.html', chunksSortMode: 'none',
minify: {
collapseWhitespace: true,
collapseInlineTagWhitespace: true,
// removeTagWhitespace: true,
removeRedundantAttributes: true,
removeEmptyAttributes: true,
removeScriptTypeAttributes: true,
removeStyleLinkTypeAttributes: true
} }),
它可以缩小index.html文件。但在项目中还有许多其他作为angular 2模板的html文件。如何对它们进行缩小处理?
我看到的其他html文件被编译成一个javascript文件-main.bundle.js。
我希望这是可能的,使用webpack。如果不行,也许有其他工具?
更新:
我检查了https://github.com/bestander/html-minify-loader,它使用https://github.com/Swaagie/minimize,并且这是它所写的:
Minimize不解析内联PHP或原始模板文件。模板不是有效的HTML,这超出了最小化的范围。应该解析和缩小模板的输出。
因此,对我来说将不起作用,因为它们是angular 2模板。
html-minify-loader
(https://github.com/bestander/html-minify-loader) - Bob Sponge