webpack学习记录(七)-打包多页应用
webpack学习记录(七)-打包多页应用
准备工作
在src下新建一个index.js和一个other.js,新建一个index.html
配置
webpack.config.js
const path = require('path')
const HtmlWepbackPlugin = require('html-webpack-plugin')
module.exports = {
plugins: [
new HtmlWebpackPlugin({
template: './src/index.html',
filename: 'index.html',
chunks: ['home']
}),
new HtmlWebpackPlugin({
template: './src/index.html',
filename: 'other.html',
chunks: ['other']
})
],
entry: {
home: './src/index.js',
other: './src/other.js'
},
output: {
filename: '[name].js',
path: path.resolve(__dirname, 'dist')
}
}

浙公网安备 33010602011771号