先上图看下config.js
的配置

-1.yarn add html-webpack-plugin
先安装抽离页面到输出的插件。
-2.const HtmlWebpackPlugin=require('html-webpack-plugin');
在配置文件顶部引入
-3.代码块贴出来,方便c v:
const path=require('path');
const HtmlWebpackPlugin=require('html-webpack-plugin');
module.exports={
mode:'development',
entry:{
home:'./src/index.js',
other:'./src/other.js'
},
output:{
filename:'[name].js',
path:path.resolve(__dirname,'dist')
},
plugins:[
new HtmlWebpackPlugin({
template:'./src/index.html',
filename:'html/home.html',
chunks:['home']
}), new HtmlWebpackPlugin({
template:'./src/index.html',
filename:'html/ohter.html',
chunks:['other']
})
]
}
网友评论