A combination of SourceMapDevToolPlugin
with custom sourceMappingURL
and output.publicPath
in Webpack configuration produces a broken sourceMappingURL
To reproduce the issue:
npm install
npx webpack-cli
This will output the bundle to the ./dist
folder.
const { SourceMapDevToolPlugin } = require("webpack");
const HtmlWebpackPlugin = require("html-webpack-plugin");
const HtmlWebpackInlineSourcePlugin = require("html-webpack-inline-source-plugin");
module.exports = {
devtool: false,
output: {
publicPath: "/foo/bar"
},
plugins: [
new HtmlWebpackPlugin({ inlineSource: ".(js|css)$" }),
new HtmlWebpackInlineSourcePlugin(),
new SourceMapDevToolPlugin({
filename: "[file].map",
append: `\n//# sourceMappingURL=https://example.com/[file].map`
})
]
};
//# sourceMappingURL=/foo/bar/https:/example.com/main.js.map
//# sourceMappingURL=https://example.com/main.js.map