About v5 version js will be inserted in front of css by default

Author: fengluoXCreated Feb 8, 2023Updated Jan 2, 2026
Labelswontfix

Hello, when we upgraded from v4 to v5, we found that the default location for inserting js has changed. Can you tell me why this change was made

v4: image v5: image webpack config: `const HtmlWebpackPlugin = require("html-webpack-plugin"); const MiniCssExtractPlugin = require("mini-css-extract-plugin");

module.exports = { mode: "production", entry: ["./src/index.js"], output: { filename: "[name].[hash:8].js", clean: true, }, module: { rules: [ { test: /.css$/, use: [MiniCssExtractPlugin.loader, "css-loader"], exclude: /node_modules/, }, { test: /.js$/, use: ["babel-loader"], exclude: /node_modules/, }, ], }, optimization: { splitChunks: { cacheGroups: { commons: { test: /[\/]node_modules[\/]/, name: "vendors", chunks: "all", }, }, }, }, plugins: [ new HtmlWebpackPlugin(), new MiniCssExtractPlugin(), ], }; `

Source: jantimon/html-webpack-plugin