You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Enables the outputting of the CSS modules mapping JSON. This can be omitted or set to a falsy value to disable any output.
1392
+
1393
+
###### `boolean`
1394
+
1395
+
Possible values:
1396
+
1397
+
-`true` - writes a JSON file next located in the same directory as the loaded resource file. For example, given a resource file located at /foo/bar/baz.css, this would write the CSS modules mapping JSON to /foo/bar/baz.css.json
Enables custom handling of the CSS modules mapping JSON output. The return value of the function is not used for anything internally and is only intended to customize output.
1423
+
1424
+
**webpack.config.js**
1425
+
1426
+
```js
1427
+
module.exports= {
1428
+
module: {
1429
+
rules: [
1430
+
{
1431
+
test:/\.css$/i,
1432
+
loader:"css-loader",
1433
+
options: {
1434
+
modules: {
1435
+
getJSON: (resourcePath, json, outputPath) => {
1436
+
// `resourcePath` is the original resource file path, e.g., /foo/bar/baz.css
1437
+
// `json` is the CSS modules map
1438
+
// `outputPath` is the expected output file path, e.g., /foo/bar/baz.css.json
exports[`"modules" option should invoke the custom getJSON function with getJSON as a function: result 1`] = `
1168
+
Array [
1169
+
Array [
1170
+
"./modules/getJSON/source.css",
1171
+
".RT7ktT7mB7tfBR25sJDZ {
1172
+
background-color: aliceblue;
1173
+
}
1174
+
1175
+
.IZmhTnK9CIeu6ww6Zjbv {
1176
+
background-color: burlywood;
1177
+
}
1178
+
1179
+
.PV11nPFlF7mzEgCXkQw4 {
1180
+
background-color: chartreuse;
1181
+
}
1182
+
1183
+
.d {
1184
+
background-color: darkgoldenrod
1185
+
}
1186
+
",
1187
+
"",
1188
+
],
1189
+
]
1190
+
`;
1191
+
1192
+
exports[`"modules" option should invoke the custom getJSON function with getJSON as a function: warnings 1`] = `Array []`;
1193
+
1125
1194
exports[`"modules" option should keep order: errors 1`] = `Array []`;
1126
1195
1127
1196
exports[`"modules" option should keep order: module 1`] = `
@@ -1194,6 +1263,69 @@ Array [
1194
1263
1195
1264
exports[`"modules" option should keep order: warnings 1`] = `Array []`;
1196
1265
1266
+
exports[`"modules" option should output a co-located CSS modules map file with getJSON as true: errors 1`] = `Array []`;
1267
+
1268
+
exports[`"modules" option should output a co-located CSS modules map file with getJSON as true: mapping 1`] = `"{\\"a\\":\\"RT7ktT7mB7tfBR25sJDZ\\",\\"b\\":\\"IZmhTnK9CIeu6ww6Zjbv\\",\\"c\\":\\"PV11nPFlF7mzEgCXkQw4\\"}"`;
1269
+
1270
+
exports[`"modules" option should output a co-located CSS modules map file with getJSON as true: module 1`] = `
1271
+
"// Imports
1272
+
import ___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___ from \\"../../../../src/runtime/noSourceMaps.js\\";
1273
+
import ___CSS_LOADER_API_IMPORT___ from \\"../../../../src/runtime/api.js\\";
1274
+
var ___CSS_LOADER_EXPORT___ = ___CSS_LOADER_API_IMPORT___(___CSS_LOADER_API_NO_SOURCEMAP_IMPORT___);
0 commit comments