Skip to content

Commit f6e05a0

Browse files
authored
docs(configuration): add css generator & parser options (#7115)
1 parent 9f7ab94 commit f6e05a0

File tree

2 files changed

+59
-16
lines changed

2 files changed

+59
-16
lines changed

src/content/configuration/experiments.mdx

Lines changed: 1 addition & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -185,16 +185,7 @@ Detect changes to remote resources and upgrade them automatically.
185185

186186
Enable native CSS support. Note that it's an experimental feature still under development and will be enabled by default in webpack v6, however you can track the progress on [GitHub](https://github.com/webpack/webpack/issues/14893).
187187

188-
- Type:
189-
190-
- `boolean`
191-
- `CssExperimentOptions`
192-
193-
```ts
194-
{
195-
exportsOnly?: boolean;
196-
}
197-
```
188+
- Type: `boolean`
198189

199190
Experimental features:
200191

@@ -210,12 +201,6 @@ Experimental features:
210201
- CSS imports: webpack will inline CSS imports into the generated CSS file.
211202
- Hot Module Reload (HMR): webpack supports HMR for CSS files. This means that changes made to CSS files will be reflected in the browser without a full page reload.
212203

213-
#### experiments.css.exportsOnly
214-
215-
Avoid generating and loading a stylesheet and only embed exports from css into output javascript files.
216-
217-
- Type: `boolean`
218-
219204
### experiments.cacheUnaffected
220205

221206
Enable additional in-memory caching of modules which are unchanged and reference only unchanged modules.

src/content/configuration/module.mdx

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,22 @@ module.exports = {
142142
'javascript/esm': {
143143
// ditto
144144
},
145+
css: {
146+
// Generator options for css modules
147+
148+
// Avoid generating and loading a stylesheet and only embed exports from css into output javascript files.
149+
// type: boolean, available since webpack 5.90.0
150+
exportsOnly: true,
151+
},
152+
'css/auto': {
153+
// ditto
154+
},
155+
'css/global': {
156+
// ditto
157+
},
158+
'css/module': {
159+
// ditto
160+
},
145161
// others…
146162
},
147163
},
@@ -162,6 +178,32 @@ module.exports = {
162178
parser: {
163179
asset: {
164180
// Parser options for asset modules
181+
182+
// The options for data url generator.
183+
dataUrl: {
184+
// Asset encoding (defaults to "base64")
185+
// type: 'base64' | false
186+
encoding: 'base64',
187+
// Asset mimetype (getting from file extension by default).
188+
// type: string
189+
mimetype: 'image/png',
190+
},
191+
192+
// Emit an output asset from this asset module. This can be set to 'false' to omit emitting e. g. for SSR.
193+
// type: boolean
194+
emit: true,
195+
196+
// Customize filename for this asset module
197+
// type: string | ((pathData: PathData, assetInfo?: AssetInfo) => string)
198+
filename: 'static/[path][name][ext]',
199+
200+
// Customize publicPath for asset modules, available since webpack 5.28.0
201+
// type: string | ((pathData: PathData, assetInfo?: AssetInfo) => string)
202+
publicPath: 'https://cdn/assets/',
203+
204+
// Emit the asset in the specified folder relative to 'output.path', available since webpack 5.67.0
205+
// type: string | ((pathData: PathData, assetInfo?: AssetInfo) => string)
206+
outputPath: 'cdn-assets/',
165207
},
166208
'asset/inline': {
167209
// No parser options are supported for this module type yet
@@ -186,6 +228,22 @@ module.exports = {
186228
'javascript/esm': {
187229
// ditto
188230
},
231+
css: {
232+
// Parser options for css modules
233+
234+
// Use ES modules named export for css exports, available since webpack 5.90.0
235+
// type: boolean
236+
namedExports: true,
237+
},
238+
'css/auto': {
239+
// ditto
240+
},
241+
'css/global': {
242+
// ditto
243+
},
244+
'css/module': {
245+
// ditto
246+
},
189247
// others…
190248
},
191249
},

0 commit comments

Comments
 (0)