1 创建html。html-webpack-plugin
cnpm i html-webpack-plugin -S
配置webpack.config.js:
//引入插件const HtmlWebpackPlugin = require("html-webpack-plugin")plugins:[new HtmlWebpackPlugin({title:"webpack-vue",//复制的页面路径template:path.resolve(__dirname,"public/index.html")})],
2 清理dist文件的插件(clean-webpack-plugi):
cnpm i clean-webpack-plugin -S
配置webpack.config.js:
//引入插件
const { CleanWebpackPlugin } = require("clean-webpack-plugin")
plugins:[
new HtmlWebpackPlugin({
title:"webpack-vue"
}),
new CleanWebpackPlugin()
],
然后再次打包的时候其他之前的出口文件会自动被清除掉。
