multi-page behavior illogical?
nordbit opened this issue · 1 comments
nordbit commented
Current behaviour 💣
var path = require('path');
var HtmlWebpackPlugin = require('../..');
var webpackMajorVersion = require('webpack/package.json').version.split('.')[0];
module.exports = {
context: __dirname,
entry: {
first: './first.js',
second: './second.js'
},
output: {
path: path.join(__dirname, 'dist/webpack-' + webpackMajorVersion),
publicPath: '',
filename: '[name].js'
},
module: {
rules: [
{ test: /\.css$/, use: ['style-loader', 'css-loader'] },
{ test: /\.png$/, type: 'asset/resource' }
]
},
plugins: [
new HtmlWebpackPlugin({
filename: '[name].html'
})
]
};
generates two html files, first.html and second.html - both with EXACTLY same content
<script defer="defer" src="first.js"></script><script defer="defer" src="second.js">
Expected behaviour ☀️
first.html:
<script defer="defer" src="first.js"></script>
second.html:
<script defer="defer" src="second.js"></script>
Reproduction Example 👾
same as in examples foder in repository
Environment 🖥
Node.js v20.10.0
linux 6.7.0-rc2
npm 10.2.3
html-webpack-plugin@5.5.4
alexander-akait commented
In such case you need to use excludeChunks
or you can setup more complex logic using multi compiler mode - create three configuration - common, first and second and use dependencies https://webpack.js.org/configuration/other-options/#dependencies, feel free to feedback