mini-css-extract-plugin
Advanced tools
@@ -15,3 +15,3 @@ "use strict"; | ||
| // eslint-disable-next-line jsdoc/no-restricted-syntax | ||
| /* eslint-disable jsdoc/reject-function-type */ | ||
| /** | ||
@@ -39,2 +39,3 @@ * @param {Function} fn any function | ||
| } | ||
| /* eslint-enable jsdoc/reject-function-type */ | ||
@@ -41,0 +42,0 @@ /** |
+25
-26
@@ -63,3 +63,3 @@ "use strict"; | ||
| * @typedef {object} NormalizedPluginOptions | ||
| * @property {Filename} filename filename | ||
| * @property {Filename=} filename filename | ||
| * @property {ChunkFilename=} chunkFilename chunk filename | ||
@@ -96,3 +96,3 @@ * @property {boolean} ignoreOrder true when need to ignore order, otherwise false | ||
| // eslint-disable-next-line jsdoc/no-restricted-syntax | ||
| // eslint-disable-next-line jsdoc/reject-any-type | ||
| /** @typedef {{ context: string | null, identifier: string, identifierIndex: number, content: Buffer, sourceMap?: Buffer, media?: string, supports?: string, layer?: any, assetsInfo?: Map<string, AssetInfo>, assets?: { [key: string]: Source }}} CssModuleDependency */ | ||
@@ -502,3 +502,2 @@ /** @typedef {Module & { content: Buffer, media?: string, sourceMap?: Buffer, supports?: string, layer?: string, assets?: { [key: string]: Source }, assetsInfo?: Map<string, AssetInfo> }} CssModule */ | ||
| this.options = { | ||
| filename: DEFAULT_FILENAME, | ||
| ignoreOrder: false, | ||
@@ -522,32 +521,32 @@ // TODO remove in the next major release | ||
| }; | ||
| if (!this.options.chunkFilename) { | ||
| const { | ||
| filename | ||
| } = this.options; | ||
| if (typeof filename !== "function") { | ||
| const hasName = /** @type {string} */filename.includes("[name]"); | ||
| const hasId = /** @type {string} */filename.includes("[id]"); | ||
| } | ||
| /** | ||
| * @param {Compiler} compiler compiler | ||
| */ | ||
| apply(compiler) { | ||
| // Finally normalize filenames based on compiler options | ||
| const normalizedFilename = this.options.filename || compiler.options.output.cssFilename || DEFAULT_FILENAME; | ||
| let normalizedChunkFilename = this.options.chunkFilename || compiler.options.output.cssChunkFilename; | ||
| if (!normalizedChunkFilename) { | ||
| if (typeof normalizedFilename !== "function") { | ||
| const hasName = /** @type {string} */normalizedFilename.includes("[name]"); | ||
| const hasId = /** @type {string} */normalizedFilename.includes("[id]"); | ||
| const hasChunkHash = /** @type {string} */ | ||
| filename.includes("[chunkhash]"); | ||
| normalizedFilename.includes("[chunkhash]"); | ||
| const hasContentHash = /** @type {string} */ | ||
| filename.includes("[contenthash]"); | ||
| normalizedFilename.includes("[contenthash]"); | ||
| // Anything changing depending on chunk is fine | ||
| if (hasChunkHash || hasContentHash || hasName || hasId) { | ||
| this.options.chunkFilename = filename; | ||
| normalizedChunkFilename = normalizedFilename; | ||
| } else { | ||
| // Otherwise prefix "[id]." in front of the basename to make it changing | ||
| this.options.chunkFilename = /** @type {string} */ | ||
| filename.replace(/(^|\/)([^/]*(?:\?|$))/, "$1[id].$2"); | ||
| normalizedChunkFilename = /** @type {string} */ | ||
| normalizedFilename.replace(/(^|\/)([^/]*(?:\?|$))/, "$1[id].$2"); | ||
| } | ||
| } else { | ||
| this.options.chunkFilename = "[id].css"; | ||
| normalizedChunkFilename = "[id].css"; | ||
| } | ||
| } | ||
| } | ||
| /** | ||
| * @param {Compiler} compiler compiler | ||
| */ | ||
| apply(compiler) { | ||
| const { | ||
@@ -643,3 +642,3 @@ webpack | ||
| chunk.canBeInitial() ? this.options.filename : this.options.chunkFilename; | ||
| chunk.canBeInitial() ? normalizedFilename : normalizedChunkFilename; | ||
| if (renderedModules.length > 0) { | ||
@@ -669,3 +668,3 @@ result.push({ | ||
| chunkGraph.getChunkModulesIterableBySourceType(chunk, MODULE_TYPE), compilation.runtimeTemplate.requestShortener); | ||
| if (modules) { | ||
| if (modules && modules.size > 0) { | ||
| const { | ||
@@ -795,3 +794,3 @@ hashFunction, | ||
| enabledChunks.add(chunk); | ||
| if (typeof this.options.chunkFilename === "string" && /\[(full)?hash(:\d+)?\]/.test(this.options.chunkFilename)) { | ||
| if (typeof normalizedChunkFilename === "string" && /\[(full)?hash(:\d+)?\]/.test(normalizedChunkFilename)) { | ||
| set.add(RuntimeGlobals.getFullHash); | ||
@@ -809,3 +808,3 @@ } | ||
| } | ||
| return referencedChunk.canBeInitial() ? (/** @type {Filename} */this.options.filename) : (/** @type {ChunkFilename} */this.options.chunkFilename); | ||
| return referencedChunk.canBeInitial() ? (/** @type {Filename} */normalizedFilename) : (/** @type {ChunkFilename} */normalizedChunkFilename); | ||
| }, set.has(RuntimeGlobals.hmrDownloadUpdateHandlers))); | ||
@@ -812,0 +811,0 @@ compilation.addRuntimeModule(chunk, new CssLoadingRuntimeModule(set, this.runtimeOptions)); |
@@ -16,3 +16,3 @@ { | ||
| "description": "Specifies a custom public path for the external resources like images, files, etc inside CSS.", | ||
| "link": "https://github.com/webpack-contrib/mini-css-extract-plugin#publicpath" | ||
| "link": "https://github.com/webpack/mini-css-extract-plugin#publicpath" | ||
| }, | ||
@@ -22,3 +22,3 @@ "emit": { | ||
| "description": "If true, emits a file (writes a file to the filesystem). If false, the plugin will extract the CSS but will not emit the file", | ||
| "link": "https://github.com/webpack-contrib/mini-css-extract-plugin#emit" | ||
| "link": "https://github.com/webpack/mini-css-extract-plugin#emit" | ||
| }, | ||
@@ -28,3 +28,3 @@ "esModule": { | ||
| "description": "Generates JS modules that use the ES modules syntax.", | ||
| "link": "https://github.com/webpack-contrib/mini-css-extract-plugin#esmodule" | ||
| "link": "https://github.com/webpack/mini-css-extract-plugin#esmodule" | ||
| }, | ||
@@ -37,5 +37,5 @@ "layer": { | ||
| "description": "Duplicate the named export with CSS modules locals to the default export (only when `esModules: true` for css-loader).", | ||
| "link": "https://github.com/webpack-contrib/mini-css-extract-plugin#defaultexports" | ||
| "link": "https://github.com/webpack/mini-css-extract-plugin#defaultexports" | ||
| } | ||
| } | ||
| } |
+3
-3
@@ -27,6 +27,6 @@ "use strict"; | ||
| // eslint-disable-next-line jsdoc/no-restricted-syntax | ||
| // eslint-disable-next-line jsdoc/reject-function-type | ||
| /** @typedef {{[key: string]: string | Function }} Locals */ | ||
| // eslint-disable-next-line jsdoc/no-restricted-syntax | ||
| // eslint-disable-next-line jsdoc/reject-any-type | ||
| /** @typedef {any} EXPECTED_ANY */ | ||
@@ -93,3 +93,3 @@ | ||
| if (!optionsFromPlugin) { | ||
| callback(new Error("You forgot to add 'mini-css-extract-plugin' plugin (i.e. `{ plugins: [new MiniCssExtractPlugin()] }`), please read https://github.com/webpack-contrib/mini-css-extract-plugin#getting-started")); | ||
| callback(new Error("You forgot to add 'mini-css-extract-plugin' plugin (i.e. `{ plugins: [new MiniCssExtractPlugin()] }`), please read https://github.com/webpack/mini-css-extract-plugin#getting-started")); | ||
| return; | ||
@@ -96,0 +96,0 @@ } |
@@ -18,3 +18,3 @@ { | ||
| "description": "This option determines the name of each output CSS file.", | ||
| "link": "https://github.com/webpack-contrib/mini-css-extract-plugin#filename" | ||
| "link": "https://github.com/webpack/mini-css-extract-plugin#filename" | ||
| }, | ||
@@ -33,3 +33,3 @@ "chunkFilename": { | ||
| "description": "This option determines the name of non-entry chunk files.", | ||
| "link": "https://github.com/webpack-contrib/mini-css-extract-plugin#chunkfilename" | ||
| "link": "https://github.com/webpack/mini-css-extract-plugin#chunkfilename" | ||
| }, | ||
@@ -39,3 +39,3 @@ "experimentalUseImportModule": { | ||
| "description": "Enable the experimental importModule approach instead of using child compilers. This uses less memory and is faster.", | ||
| "link": "https://github.com/webpack-contrib/mini-css-extract-plugin#experimentaluseimportmodule" | ||
| "link": "https://github.com/webpack/mini-css-extract-plugin#experimentaluseimportmodule" | ||
| }, | ||
@@ -45,7 +45,7 @@ "ignoreOrder": { | ||
| "description": "Remove Order Warnings.", | ||
| "link": "https://github.com/webpack-contrib/mini-css-extract-plugin#ignoreorder" | ||
| "link": "https://github.com/webpack/mini-css-extract-plugin#ignoreorder" | ||
| }, | ||
| "insert": { | ||
| "description": "Inserts the `link` tag at the given position for non-initial (async) (https://webpack.js.org/concepts/under-the-hood/#chunks) CSS chunks.", | ||
| "link": "https://github.com/webpack-contrib/mini-css-extract-plugin#insert", | ||
| "link": "https://github.com/webpack/mini-css-extract-plugin#insert", | ||
| "anyOf": [ | ||
@@ -62,3 +62,3 @@ { | ||
| "description": "Adds custom attributes to the `link` tag for non-initial (async) (https://webpack.js.org/concepts/under-the-hood/#chunks) CSS chunks.", | ||
| "link": "https://github.com/webpack-contrib/mini-css-extract-plugin#attributes", | ||
| "link": "https://github.com/webpack/mini-css-extract-plugin#attributes", | ||
| "type": "object" | ||
@@ -76,3 +76,3 @@ }, | ||
| "description": "This option allows loading asynchronous chunks with a custom link type", | ||
| "link": "https://github.com/webpack-contrib/mini-css-extract-plugin#linktype" | ||
| "link": "https://github.com/webpack/mini-css-extract-plugin#linktype" | ||
| }, | ||
@@ -82,5 +82,5 @@ "runtime": { | ||
| "description": "Enabled/Disables runtime generation. CSS will be still extracted and can be used for a custom loading methods.", | ||
| "link": "https://github.com/webpack-contrib/mini-css-extract-plugin#noRuntime" | ||
| "link": "https://github.com/webpack/mini-css-extract-plugin#noRuntime" | ||
| } | ||
| } | ||
| } |
+5
-3
@@ -9,3 +9,3 @@ "use strict"; | ||
| // eslint-disable-next-line jsdoc/no-restricted-syntax | ||
| // eslint-disable-next-line jsdoc/reject-any-type | ||
| /** @typedef {import("webpack").LoaderContext<any>} LoaderContext */ | ||
@@ -39,3 +39,3 @@ | ||
| // eslint-disable-next-line jsdoc/no-restricted-syntax | ||
| /* eslint-disable jsdoc/reject-any-type */ | ||
| /** | ||
@@ -57,2 +57,3 @@ * @param {LoaderContext} loaderContext loader context | ||
| } | ||
| /* eslint-enable jsdoc/reject-any-type */ | ||
@@ -175,3 +176,3 @@ /** | ||
| // eslint-disable-next-line jsdoc/no-restricted-syntax | ||
| /* eslint-disable jsdoc/reject-function-type */ | ||
| /** | ||
@@ -184,2 +185,3 @@ * @param {string | Function} value local | ||
| } | ||
| /* eslint-enable jsdoc/reject-function-type */ | ||
@@ -186,0 +188,0 @@ /** |
+9
-9
| { | ||
| "name": "mini-css-extract-plugin", | ||
| "version": "2.9.4", | ||
| "version": "2.10.0", | ||
| "description": "extracts CSS into separate files", | ||
@@ -11,5 +11,5 @@ "keywords": [ | ||
| ], | ||
| "homepage": "https://github.com/webpack-contrib/mini-css-extract-plugin", | ||
| "bugs": "https://github.com/webpack-contrib/mini-css-extract-plugin/issues", | ||
| "repository": "webpack-contrib/mini-css-extract-plugin", | ||
| "homepage": "https://github.com/webpack/mini-css-extract-plugin", | ||
| "bugs": "https://github.com/webpack/mini-css-extract-plugin/issues", | ||
| "repository": "webpack/mini-css-extract-plugin", | ||
| "funding": { | ||
@@ -34,3 +34,3 @@ "type": "opencollective", | ||
| "clean": "del-cli dist", | ||
| "commitlint": "commitlint --from=master", | ||
| "commitlint": "commitlint --from=main", | ||
| "lint:prettier": "prettier \"{**/*,*}.{js,json,md,yml,css,ts}\" --list-different", | ||
@@ -82,8 +82,8 @@ "lint:code": "eslint --cache .", | ||
| "eslint-plugin-jest": "^29.0.1", | ||
| "eslint-plugin-jsdoc": "^52.0.0", | ||
| "eslint-plugin-jsdoc": "^62.0.0", | ||
| "eslint-plugin-n": "^17.21.0", | ||
| "eslint-plugin-prettier": "^5.5.3", | ||
| "eslint-plugin-unicorn": "^60.0.0", | ||
| "eslint-plugin-unicorn": "^62.0.0", | ||
| "file-loader": "^6.2.0", | ||
| "globals": "^16.3.0", | ||
| "globals": "^17.0.0", | ||
| "husky": "^7.0.0", | ||
@@ -103,3 +103,3 @@ "jest": "^28.1.3", | ||
| "typescript-eslint": "^8.38.0", | ||
| "webpack": "^5.91.0", | ||
| "webpack": "^5.102.0", | ||
| "webpack-cli": "^4.9.2", | ||
@@ -106,0 +106,0 @@ "webpack-dev-server": "^5.2.1" |
+9
-9
@@ -49,3 +49,3 @@ <div align="center"> | ||
| It's recommended to combine `mini-css-extract-plugin` with the [`css-loader`](https://github.com/webpack-contrib/css-loader) | ||
| It's recommended to combine `mini-css-extract-plugin` with the [`css-loader`](https://github.com/webpack/css-loader) | ||
@@ -92,3 +92,3 @@ Then add the loader and the plugin to your `webpack` configuration. For example: | ||
| > | ||
| > Source maps works only for `source-map`/`nosources-source-map`/`hidden-nosources-source-map`/`hidden-source-map` values because CSS only supports source maps with the `sourceMappingURL` comment (i.e. `//# sourceMappingURL=style.css.map`). If you need set `devtool` to another value you can enable source maps generation for extracted CSS using [`sourceMap: true`](https://github.com/webpack-contrib/css-loader#sourcemap) for `css-loader`. | ||
| > Source maps works only for `source-map`/`nosources-source-map`/`hidden-nosources-source-map`/`hidden-source-map` values because CSS only supports source maps with the `sourceMappingURL` comment (i.e. `//# sourceMappingURL=style.css.map`). If you need set `devtool` to another value you can enable source maps generation for extracted CSS using [`sourceMap: true`](https://github.com/webpack/css-loader#sourcemap) for `css-loader`. | ||
@@ -616,3 +616,3 @@ ## Options | ||
| For `production` builds, it is recommended to extract the CSS from your bundle being able to use parallel loading of CSS/JS resources later on. This can be achieved by using the `mini-css-extract-plugin`, because it creates separate css files. | ||
| For `development` mode (including `webpack-dev-server`) you can use [style-loader](https://github.com/webpack-contrib/style-loader), because it injects CSS into the DOM using multiple <style></style> and works faster. | ||
| For `development` mode (including `webpack-dev-server`) you can use [style-loader](https://github.com/webpack/style-loader), because it injects CSS into the DOM using multiple <style></style> and works faster. | ||
@@ -891,3 +891,3 @@ > Important: Do not use `style-loader` and `mini-css-extract-plugin` together. | ||
| To minify the output, use a plugin like [css-minimizer-webpack-plugin](https://github.com/webpack-contrib/css-minimizer-webpack-plugin). | ||
| To minify the output, use a plugin like [css-minimizer-webpack-plugin](https://github.com/webpack/css-minimizer-webpack-plugin). | ||
@@ -1273,3 +1273,3 @@ **webpack.config.js** | ||
| source, | ||
| `${varNames.tag}.setAttribute("href", "https://github.com/webpack-contrib/mini-css-extract-plugin");`, | ||
| `${varNames.tag}.setAttribute("href", "https://github.com/webpack/mini-css-extract-plugin");`, | ||
| ]), | ||
@@ -1294,6 +1294,6 @@ ); | ||
| [node-url]: https://nodejs.org | ||
| [tests]: https://github.com/webpack-contrib/mini-css-extract-plugin/workflows/mini-css-extract-plugin/badge.svg | ||
| [tests-url]: https://github.com/webpack-contrib/mini-css-extract-plugin/actions | ||
| [cover]: https://codecov.io/gh/webpack-contrib/mini-css-extract-plugin/branch/master/graph/badge.svg | ||
| [cover-url]: https://codecov.io/gh/webpack-contrib/mini-css-extract-plugin | ||
| [tests]: https://github.com/webpack/mini-css-extract-plugin/workflows/mini-css-extract-plugin/badge.svg | ||
| [tests-url]: https://github.com/webpack/mini-css-extract-plugin/actions | ||
| [cover]: https://codecov.io/gh/webpack/mini-css-extract-plugin/branch/main/graph/badge.svg | ||
| [cover-url]: https://codecov.io/gh/webpack/mini-css-extract-plugin | ||
| [discussion]: https://img.shields.io/github/discussions/webpack/webpack | ||
@@ -1300,0 +1300,0 @@ [discussion-url]: https://github.com/webpack/webpack/discussions |
+2
-2
@@ -145,3 +145,3 @@ export = MiniCssExtractPlugin; | ||
| * @typedef {object} NormalizedPluginOptions | ||
| * @property {Filename} filename filename | ||
| * @property {Filename=} filename filename | ||
| * @property {ChunkFilename=} chunkFilename chunk filename | ||
@@ -243,3 +243,3 @@ * @property {boolean} ignoreOrder true when need to ignore order, otherwise false | ||
| */ | ||
| filename: Filename; | ||
| filename?: Filename | undefined; | ||
| /** | ||
@@ -246,0 +246,0 @@ * chunk filename |
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Debug access
Supply chain riskUses debug, reflection and dynamic code execution features.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
139987
0.11%2756
0.07%