forked from firefox-devtools/debugger
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.devtools.js
More file actions
49 lines (41 loc) · 1.42 KB
/
webpack.config.devtools.js
File metadata and controls
49 lines (41 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
"use strict";
const path = require("path");
const webpack = require('webpack');
const getConfig = require("./config/config").getConfig;
const { DefinePlugin } = webpack;
const ignoreRegexes = [
/chrome-remote-debug-protocol/
];
const nativeMapping = {
"public/js/utils/source-editor": "devtools/client/sourceeditor/editor"
};
module.exports = webpackConfig => {
webpackConfig.output.library = "Debugger";
webpackConfig.externals = [
function(context, request, callback) {
const mod = path.join(context.replace(__dirname + "/", ""), request);
// Any matching paths here won't be included in the bundle.
if(ignoreRegexes.some(r => r.test(request))) {
callback(null, "var {}");
return;
} else if(nativeMapping[mod]) {
callback(null, "var devtoolsRequire('" + nativeMapping[mod] + "')");
return;
}
callback();
},
{ codemirror: "var devtoolsRequire('devtools/client/sourceeditor/editor')" }
];
// Remove the existing DefinePlugin so we can override it.
const plugins = webpackConfig.plugins.filter(p => !(p instanceof DefinePlugin));
webpackConfig.plugins = plugins.concat([
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify(process.env.NODE_ENV || "production"),
TARGET: JSON.stringify("firefox-panel")
},
"DebuggerConfig": JSON.stringify(getConfig())
})
]);
return webpackConfig;
};