Consult the webpack plug-in mini-css-extract-plugin configuration item

what do the filename and chunkFilename configuration items in the following figure mean?

Why is the file name I generated 2.css ?

since this plug-in is used to package all css into one file, can I fix the name?

clipboard.png

clipboard.png

Mar.29,2021

the [id] and [name] in the diagram you give are called placeholder in webpack.

is used to dynamically replace content (essentially regular substitution) after the webpack is built.

then answer your question:

  1. What do filename and chunkFilenam e mean

these two configurations exist in the output of webpack, and mini-css-extract-plugin also said that these two configurations have the same meaning as the output configuration on the
official website.

filename is simply named after the name in entry , which is static .
chunkFilename is generated when builds the application (the user can also specify a name), not in the configuration (such as configuration refers to entry).

  1. can I fix the name?

modify chunkFilename to another value. You can fix the name (such as chunkFilename: "a.css"), or you can use the placeholder of webpack for
. The placeholders above are id,name and so on.

I hope my answer can help you. Thank you.


you should modify this configuration item;

chunkFilename: "xxx.css"

chunkFilename: "[name].css"
Menu