Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

experiments.css is not equivalent to the mini-css-extract-plugin it's meant to replace #17700

Closed
fregante opened this issue Sep 24, 2023 · 1 comment

Comments

@fregante
Copy link

fregante commented Sep 24, 2023

Bug report

mini-css-extract-plugin can be used to extract every imported stylesheets into a single file, without also loading it. This is the default behavior of the plugin.

This behavior is absent from experiments.css.

What is the current behavior?

Using experiments.css = true:

  • import "./style.css" creates main.css and it will attempt to load the file
  • new URL("./style.css", import.meta.url) creates multiple [hash].css files and it won't attempt to load them

If the current behavior is a bug, please provide the steps to reproduce.

You can find the source and dist results in https://github.com/fregante/webpack-sandbox/tree/main/experiments.css

In short, the config is just {experiments: {css: true}}

What is the expected behavior?

It should match the behavior of the previous plugin, which just created a unified main.css file and did not attempt to load it. As a bonus, the resulting main.js is completely empty:

module: {
	rules: [
		{
			test: /\.css$/,
			use: [
				MiniCssExtractPlugin.loader,
				'css-loader',
			],
		},
	]
},
plugins: [
	new MiniCssExtractPlugin(),
],

Other relevant information:
webpack version: 5.88.2
Node.js version: 18
Operating System: macOS
Additional tools:

Originally reported in #14893 (comment)

@alexander-akait
Copy link
Member

The new logic will autoload stylsheets by default, because it will allow preload/prefetch/track loaded modules and etc, we will provide an option to disable such behaviour, so close in favor #14893 (I updated our roadmap)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants