webpack-02-html插件及webpack-dev-server

webpack-dev-server

开发环境配置

1
2
3
4
5
6
7
devServer: { // 开发服务器的配置 
port: 3000, // 端口号
progress: true, // 显示进度条
contentBase: ('./dist'), // 设置启动目录
open: true, // 打开浏览器
compress : true, // 资源采用gzip压缩
},

webpack配置插件

1
plugins:[]

html-webpack-plugin

打包html文件

1
2
3
4
5
6
7
8
9
new HtmlWebpackPlugin({  
template: './src/index.html',
filename: 'index.html',
minify: {
removeAttributeQuotes: true, // 删除双引号
collapseWhitespace: true, // 压缩空行
},
hash: true, // 给生成的js文件,添加hash戳(比如:bundle.ab24e2bd.js?ab24e2bd1cf2c8ab6a33)
})
0%