diff --git a/src/plugin-options.json b/src/plugin-options.json index 7cacd20b..eea6cfd1 100644 --- a/src/plugin-options.json +++ b/src/plugin-options.json @@ -20,7 +20,9 @@ "chunkFilename": { "anyOf": [ { - "type": "string" + "type": "string", + "absolutePath": false, + "minLength": 1 }, { "instanceof": "Function" diff --git a/test/__snapshots__/validate-plugin-options.test.js.snap b/test/__snapshots__/validate-plugin-options.test.js.snap index d49a9884..ff8fb308 100644 --- a/test/__snapshots__/validate-plugin-options.test.js.snap +++ b/test/__snapshots__/validate-plugin-options.test.js.snap @@ -8,17 +8,32 @@ exports[`validate options should throw an error on the "attributes" option with -> Read more at https://github.com/webpack-contrib/mini-css-extract-plugin#attributes" `; +exports[`validate options should throw an error on the "chunkFilename" option with "" value 1`] = ` +"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema. + - options.chunkFilename should be a non-empty string." +`; + +exports[`validate options should throw an error on the "chunkFilename" option with "/styles/[id].css" value 1`] = ` +"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema. + - options.chunkFilename: A relative path is expected. However, the provided value \\"/styles/[id].css\\" is an absolute path!" +`; + exports[`validate options should throw an error on the "chunkFilename" option with "true" value 1`] = ` "Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema. - options.chunkFilename should be one of these: - string | function + non-empty string | function -> This option determines the name of non-entry chunk files. -> Read more at https://github.com/webpack-contrib/mini-css-extract-plugin#chunkfilename Details: - * options.chunkFilename should be a string. + * options.chunkFilename should be a non-empty string. * options.chunkFilename should be an instance of function." `; +exports[`validate options should throw an error on the "filename" option with "" value 1`] = ` +"Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema. + - options.filename should be a non-empty string." +`; + exports[`validate options should throw an error on the "filename" option with "/styles/[name].css" value 1`] = ` "Invalid options object. Mini CSS Extract Plugin has been initialized using an options object that does not match the API schema. - options.filename: A relative path is expected. However, the provided value \\"/styles/[name].css\\" is an absolute path!" diff --git a/test/validate-plugin-options.test.js b/test/validate-plugin-options.test.js index aedefa96..ff95fbfc 100644 --- a/test/validate-plugin-options.test.js +++ b/test/validate-plugin-options.test.js @@ -7,11 +7,11 @@ describe("validate options", () => { "[name].css", ({ name }) => `${name.replace("/js/", "/css/")}.css`, ], - failure: [true, "/styles/[name].css"], + failure: [true, "/styles/[name].css", ""], }, chunkFilename: { success: ["[id].css", ({ chunk }) => `${chunk.id}.${chunk.name}.css`], - failure: [true], + failure: [true, "/styles/[id].css", ""], }, ignoreOrder: { success: [true, false],