/
githubmirror
/
webpack
Обзор
Документация
Войти
/
githubmirror
/
webpack
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
test/configCases/source-map/devtool-and-source-map-plugin/webpack.config.js
85 строк
2 KB
Alexander Akait
fix: allow devtool and SourceMapDevToolPlugin to coexist on the same asset (#21001)
21 май 2026, 15:41
Не верифицирован
21 май 2026, 15:41
67b7419
Код
Авторство
О чём код?
"use strict"; const webpack = require("../../../../"); /** @type {import("../../../../").Configuration[]} */ module.exports = [ // 1. `devtool: 'hidden-source-map'` (no sourceMappingURL appended) + // a `SourceMapDevToolPlugin` that emits a second nosources map and appends // its URL. This is the exact configuration sokra suggested in #6813. { devtool: "hidden-source-map", entry: "./primary.js", output: { filename: "primary.js" }, plugins: [ new webpack.SourceMapDevToolPlugin({ filename: "[file].secondary.map", noSources: true }) ] }, // 2. `devtool: false` + two `SourceMapDevToolPlugin` instances writing to // different filenames for the same asset. { devtool: false, entry: "./dual.js", output: { filename: "dual.js" }, plugins: [ new webpack.SourceMapDevToolPlugin({ filename: "[file].full.map", append: false }), new webpack.SourceMapDevToolPlugin({ filename: "[file].nosources.map", noSources: true }) ] }, // 3. Three `SourceMapDevToolPlugin` instances on the same asset — exercises // the `related.sourceMap` array-merge path where the asset info already // has an array (rather than a single string) from the prior two plugins. { devtool: false, entry: "./triple.js", output: { filename: "triple.js" }, plugins: [ new webpack.SourceMapDevToolPlugin({ filename: "[file].a.map", append: false }), new webpack.SourceMapDevToolPlugin({ filename: "[file].b.map", append: false, noSources: true }), new webpack.SourceMapDevToolPlugin({ filename: "[file].c.map", sourceRoot: "triple" }) ] }, // 4. `debugIds: true` combined with a function `append` — exercises the // branch that wraps the user's callback so the `//# debugId=` comment is // prepended at call time instead of stringifying the function. { devtool: false, entry: "./debug-fn.js", output: { filename: "debug-fn.js" }, plugins: [ new webpack.SourceMapDevToolPlugin({ filename: "[file].map", debugIds: true, append: (pathData) => `\n//# sourceMappingURL=https://example.invalid/${pathData.filename}.map` }) ] } ];