plugin:类似生命周期函数
1.npm install--save-dev html-webpack-plugin
const HtmlWebpackPlugin=require('html-webpack-plugin');
const path=require('path');
module.exports={
entry:'index.js',
output:{
path:path.resolve(__dirname,'./dist'),
filename:'index_bundle.js'
},
plugins: [
new HtmlWebpackPlugin(
{ template:'./src/index.html'}
)
]
};
2.打包后自动生成dist/index.html,并把打包生成的js文件自动引入到index.html页面上
网友评论