webpack打包多页
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]bundle.js',
path: path.resolve(__dirname, 'dist')
},
plugins: [
new htmlWebpackPlugin({
template: "./index.html",
filename: "home.html",
chunks: ['home']
}), new htmlWebpackPlugin({
template: "./index.html",
filename: "other.html",
chunks: ['other']
})
]
};
网友评论