Skip to content

Commit fd8e0aa

Browse files
committed
fix: do not allow absolute path in chunkFilename
1 parent 76361df commit fd8e0aa

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

src/plugin-options.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
"chunkFilename": {
2121
"anyOf": [
2222
{
23-
"type": "string"
23+
"type": "string",
24+
"absolutePath": false,
25+
"minLength": 1
2426
},
2527
{
2628
"instanceof": "Function"

test/__snapshots__/validate-plugin-options.test.js.snap

+7-2
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,19 @@ exports[`validate options should throw an error on the "attributes" option with
88
-> Read more at https://github.com/webpack-contrib/mini-css-extract-plugin#attributes"
99
`;
1010

11+
exports[`validate options should throw an error on the "chunkFilename" option with "/styles/[id].css" value 1`] = `
12+
"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema.
13+
- options.chunkFilename: A relative path is expected. However, the provided value \\"/styles/[id].css\\" is an absolute path!"
14+
`;
15+
1116
exports[`validate options should throw an error on the "chunkFilename" option with "true" value 1`] = `
1217
"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema.
1318
- options.chunkFilename should be one of these:
14-
string | function
19+
non-empty string | function
1520
-> This option determines the name of non-entry chunk files.
1621
-> Read more at https://github.com/webpack-contrib/mini-css-extract-plugin#chunkfilename
1722
Details:
18-
* options.chunkFilename should be a string.
23+
* options.chunkFilename should be a non-empty string.
1924
* options.chunkFilename should be an instance of function."
2025
`;
2126

test/validate-plugin-options.test.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ describe("validate options", () => {
1111
},
1212
chunkFilename: {
1313
success: ["[id].css", ({ chunk }) => `${chunk.id}.${chunk.name}.css`],
14-
failure: [true],
14+
failure: [true, "/styles/[id].css"],
1515
},
1616
ignoreOrder: {
1717
success: [true, false],

0 commit comments

Comments
 (0)