From f8171f52bb01d4fb8a8052b92d592dacb5739377 Mon Sep 17 00:00:00 2001 From: Sam Chen Date: Sun, 25 Jun 2023 21:11:04 +0800 Subject: [PATCH] docs(Configuration): document css/auto --- src/content/configuration/module.mdx | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/src/content/configuration/module.mdx b/src/content/configuration/module.mdx index fcb096770f6d..77f234830859 100644 --- a/src/content/configuration/module.mdx +++ b/src/content/configuration/module.mdx @@ -1034,7 +1034,7 @@ Include all modules that pass test assertion. If you supply a `Rule.test` option `string` -Possible values: `'javascript/auto' | 'javascript/dynamic' | 'javascript/esm' | 'json' | 'webassembly/sync' | 'webassembly/async' | 'asset' | 'asset/source' | 'asset/resource' | 'asset/inline'` +Possible values: `'javascript/auto' | 'javascript/dynamic' | 'javascript/esm' | 'json' | 'webassembly/sync' | 'webassembly/async' | 'asset' | 'asset/source' | 'asset/resource' | 'asset/inline' | 'css/auto'` `Rule.type` sets the type for a matching module. This prevents defaultRules and their default importing behaviors from occurring. For example, if you want to load a `.json` file through a custom loader, you'd need to set the `type` to `javascript/auto` to bypass webpack's built-in json importing. (See [v4.0 changelog](https://github.com/webpack/webpack/releases/tag/v4.0.0) for more details) @@ -1058,6 +1058,31 @@ module.exports = { > See [Asset Modules guide](/guides/asset-modules/) for more about `asset*` type. +### css/auto + + + +See use case of `css/auto` module type [here](https://github.com/webpack/webpack/issues/16572). Make sure to enable [`experiments.css`](/configuration/experiments/#experimentscss) to use `css/auto`. + +```js +module.exports = { + target: 'web', + mode: 'development', + experiments: { + css: true, + }, + module: { + rules: [ + { + test: /\.less$/, + use: 'less-loader', + type: 'css/auto', + }, + ], + }, +}; +``` + ## Rule.use `[UseEntry]` `function(info)`