const HtmlWebpackPlugin = require('html-webpack-plugin'); module.exports = { entry: { app1: './src/app1.js', app2: './src/app2.js' }, output: { filename: '[name].bundle.js', path: path.resolve(__dirname, 'dist') }, plugins: [ new HtmlWebpackPlugin({ template: './src/index.html', filename: 'app1.html', chunks: ['app1'] }), new HtmlWebpackPlugin({ template: './src/index.html', filename: 'app2.html', chunks: ['app2'] }) ] };
这样配置后,Webpack 将会根据每个入口文件的配置,分别生成对应的 HTML 文件,并自动引入正确的 JavaScript 文件。
标签:src,webpack5,app2,app1,filename,html,HtmlWebpackPlugin From: https://www.cnblogs.com/idontcare/p/18046123