Skip to content

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

@fengluoX

Description

@fengluoX

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(),
],
};
`

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions