1. 在webpack.config.js文件中復制添加內容
~~~
const path = require('path');
const HtmlWebpackPlugin = require('html-webpack-plugin');
module.exports = {
entry: './src/index.js', //表示文件的入口
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'bundle.js' //表示文件出口
},
//添加的html文件
plugins: [
new HtmlWebpackPlugin({
title:"打包文件",
//js插入的位置
inject:"head",
//生成的模板
template:"index.html",
//生成的html的文件夾名
//filename:'[hash]-index.html,
//date:new Date() ,
minify:{
removeComets:true,
collapseInlineTagWhitespace:true,
collapseWhitespace:true
}
})
] ,
~~~
~~~
minify:{
removeComets:true,
collapseInlineTagWhitespace:true,
collapseWhitespace:true
}
~~~