From 3a12e52797b2c313972b4ccb59d9840be67abf63 Mon Sep 17 00:00:00 2001 From: Sam Chen Date: Fri, 16 Jun 2023 09:41:55 +0800 Subject: [PATCH 1/2] docs(plugins): document append function --- src/content/plugins/eval-source-map-dev-tool-plugin.mdx | 9 ++++++++- src/content/plugins/source-map-dev-tool-plugin.mdx | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/content/plugins/eval-source-map-dev-tool-plugin.mdx b/src/content/plugins/eval-source-map-dev-tool-plugin.mdx index d80530fff410..ecdde00dcdd8 100644 --- a/src/content/plugins/eval-source-map-dev-tool-plugin.mdx +++ b/src/content/plugins/eval-source-map-dev-tool-plugin.mdx @@ -29,7 +29,14 @@ The following options are supported: - `test` (`string|RegExp|array`): Include source maps for modules based on their extension (defaults to `.js` and `.css`). - `include` (`string|RegExp|array`): Include source maps for module paths that match the given value. - `exclude` (`string|RegExp|array`): Exclude modules that match the given value from source map generation. -- `append` (`string`): Appends the given value to the original asset. Usually the `#sourceMappingURL` comment. `[url]` is replaced with a URL to the source map file. `false` disables the appending. +- `append` (`string|function`): Appends the given value to the original asset. Usually the `#sourceMappingURL` comment. `[url]` is replaced with a URL to the source map file. `false` disables the appending. + + Since webpack 5.84.0, `append` can be a function that takes the path data and asset info object as arguments and returns a string: + + ```ts + (pathData: PathData, assetInfo?: AssetInfo) => string; + ``` + - `moduleFilenameTemplate` (`string`): See [`output.devtoolModuleFilenameTemplate`](/configuration/output/#outputdevtoolmodulefilenametemplate). - `module` (`boolean`): Indicates whether loaders should generate source maps (defaults to `true`). - `columns` (`boolean`): Indicates whether column mappings should be used (defaults to `true`). diff --git a/src/content/plugins/source-map-dev-tool-plugin.mdx b/src/content/plugins/source-map-dev-tool-plugin.mdx index 1dc3c6574092..7b136e616162 100644 --- a/src/content/plugins/source-map-dev-tool-plugin.mdx +++ b/src/content/plugins/source-map-dev-tool-plugin.mdx @@ -27,7 +27,14 @@ The following options are supported: - `include` (`string` `RegExp` `[string, RegExp]`): Include source maps for module paths that match the given value. - `exclude` (`string` `RegExp` `[string, RegExp]`): Exclude modules that match the given value from source map generation. - `filename` (`string`): Defines the output filename of the SourceMap (will be inlined if no value is provided). -- `append` (`string`): Appends the given value to the original asset. Usually the `#sourceMappingURL` comment. `[url]` is replaced with a URL to the source map file. Since webpack v4.36.0, path parameters are supported: `[chunk]`, `[filename]` and `[contenthash]`. Setting `append` to `false` disables the appending. +- `append` (`string` `function`): Appends the given value to the original asset. Usually the `#sourceMappingURL` comment. `[url]` is replaced with a URL to the source map file. Since webpack v4.36.0, path parameters are supported: `[chunk]`, `[filename]` and `[contenthash]`. Setting `append` to `false` disables the appending. + + Since webpack 5.84.0, `append` can be a function that takes the path data and asset info object as arguments and returns a string: + + ```ts + (pathData: PathData, assetInfo?: AssetInfo) => string; + ``` + - `moduleFilenameTemplate` (`string`): See [`output.devtoolModuleFilenameTemplate`](/configuration/output/#outputdevtoolmodulefilenametemplate). - `fallbackModuleFilenameTemplate` (`string`): See link above. - `namespace` (`string`): See [`output.devtoolNamespace`](/configuration/output/#outputdevtoolnamespace). From 70219d876bd91e354db1e02fc75453904e20e345 Mon Sep 17 00:00:00 2001 From: Sam Chen Date: Sun, 18 Jun 2023 14:33:34 +0800 Subject: [PATCH 2/2] Apply suggestions from code review --- src/content/plugins/eval-source-map-dev-tool-plugin.mdx | 2 +- src/content/plugins/source-map-dev-tool-plugin.mdx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/content/plugins/eval-source-map-dev-tool-plugin.mdx b/src/content/plugins/eval-source-map-dev-tool-plugin.mdx index ecdde00dcdd8..7e404b243054 100644 --- a/src/content/plugins/eval-source-map-dev-tool-plugin.mdx +++ b/src/content/plugins/eval-source-map-dev-tool-plugin.mdx @@ -31,7 +31,7 @@ The following options are supported: - `exclude` (`string|RegExp|array`): Exclude modules that match the given value from source map generation. - `append` (`string|function`): Appends the given value to the original asset. Usually the `#sourceMappingURL` comment. `[url]` is replaced with a URL to the source map file. `false` disables the appending. - Since webpack 5.84.0, `append` can be a function that takes the path data and asset info object as arguments and returns a string: + Starting from version 5.84.0, webpack allows the `append` option to be a function that accepts path data and an asset info object as arguments, and returns a string. ```ts (pathData: PathData, assetInfo?: AssetInfo) => string; diff --git a/src/content/plugins/source-map-dev-tool-plugin.mdx b/src/content/plugins/source-map-dev-tool-plugin.mdx index 7b136e616162..08626419337e 100644 --- a/src/content/plugins/source-map-dev-tool-plugin.mdx +++ b/src/content/plugins/source-map-dev-tool-plugin.mdx @@ -29,7 +29,7 @@ The following options are supported: - `filename` (`string`): Defines the output filename of the SourceMap (will be inlined if no value is provided). - `append` (`string` `function`): Appends the given value to the original asset. Usually the `#sourceMappingURL` comment. `[url]` is replaced with a URL to the source map file. Since webpack v4.36.0, path parameters are supported: `[chunk]`, `[filename]` and `[contenthash]`. Setting `append` to `false` disables the appending. - Since webpack 5.84.0, `append` can be a function that takes the path data and asset info object as arguments and returns a string: + Starting from version 5.84.0, webpack allows the `append` option to be a function that accepts path data and an asset info object as arguments, and returns a string. ```ts (pathData: PathData, assetInfo?: AssetInfo) => string;