Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 22 additions & 1 deletion packages/react-devtools-extensions/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,28 @@ module.exports = {
}),
new Webpack.SourceMapDevToolPlugin({
filename: '[file].map',
include: ['installHook.js', 'react_devtools_backend_compact.js'],
include: ['installHook.js'],
noSources: !__DEV__,
// In production, don't append the sourceMappingURL comment. installHook.js
// runs in the page's MAIN world, so browsers resolve the source map URL
// relative to the page origin (not the extension URL), causing a failed
// network request and a console warning in every app with DevTools installed.
append: __DEV__ ? undefined : false,
// https://github.com/webpack/webpack/issues/3603#issuecomment-1743147144
moduleFilenameTemplate(info) {
const {absoluteResourcePath, namespace, resourcePath} = info;

if (isAbsolute(absoluteResourcePath)) {
return relative(__dirname + '/build', absoluteResourcePath);
}

// Mimic Webpack's default behavior:
return `webpack://${namespace}/${resourcePath}`;
},
}),
new Webpack.SourceMapDevToolPlugin({
filename: '[file].map',
include: ['react_devtools_backend_compact.js'],
noSources: !__DEV__,
// https://github.com/webpack/webpack/issues/3603#issuecomment-1743147144
moduleFilenameTemplate(info) {
Expand Down