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')
    }
}
posted @ 2020-03-16 11:18  Arohaa  阅读(98)  评论(0)    收藏  举报