webpack对html压缩,求助,webpack 如何打包html,在html中可以压缩哪些东西?如何配置?...
发布日期:2021-10-27 11:21:02 浏览次数:9 分类:技术文章

本文共 595 字,大约阅读时间需要 1 分钟。

1. 安装: html-webpack-plugin 插件完成打包

2. 命令:npm install html-webpack-plugin –save-dev

3. 配置:

引入:const HtmlWebpackPlugin = require('html-webpack-plugin');

module.exports = {

entry: 'index.js',

output: {

path: __dirname + '/dist',

filename: 'index_bundle.js'

},

plugins: [

new HtmlWebpackPlugin({

title: 'My App',(生成的页面标题)

filename: 'assets/admin.html',(生成的文件名)

template: 'src/assets/test.html',(原来的index.html)

minify: {

collapseWhitespace: true,

removeComments: true,

removeRedundantAttributes: true,

removeScriptTypeAttributes: true,

removeStyleLinkTypeAttributes: true,

useShortDoctype: true

}

})

]

转载地址:https://blog.csdn.net/weixin_34518190/article/details/117782749 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!

上一篇:html盒子模型 正方形嵌套,div盒子模型实例
下一篇:android漏洞公告,7月份Android安全公告公布 已修复多个严重漏洞

发表评论

最新留言

逛到本站,mark一下
[***.202.152.39]2024年04月17日 14时10分50秒