萌新自己学习webpack做的简单配置,如有错误请多包含,也可指点,谢谢.
// An highlighted block
const path = require('path')
const HtmlWebpackPlugin = require('html-webpack-plugin')
module.exports = {
mode: 'development',
// 多入口
entry: {
home: './src/index.js',
other: './src/other.js'
},
output: {
// [name] home,other
filename: '[name].js',
path: path.resolve(__dirname,'dist')
},
plugins: [ // 数组 存放所有的webpack插件
new HtmlWebpackPlugin({
template: './index.html', // 模板
filename: 'home.html', // 打包后文件名
chunks: ['home'], // 配置引用资源
}),
new HtmlWebpackPlugin({
template: './index.html', // 模板
filename: 'other.html', // 打包后文件名
chunks: ['home','other'], // 配置引用资源
})
],
}