forked from firefox-devtools/devtools-core
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
62 lines (51 loc) · 2.06 KB
/
webpack.config.js
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
50
51
52
53
54
55
56
57
58
59
60
61
62
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
const { toolboxConfig } = require("devtools-launchpad/index");
const getConfig = require("./bin/getConfig");
const {isDevelopment, isFirefoxPanel} = require("devtools-config");
const ObjectRestSpreadPlugin = require("@sucrase/webpack-object-rest-spread-plugin");
const path = require("path");
const projectPath = path.join(__dirname, "src");
let webpackConfig = {
entry: {
reps: [path.join(projectPath, "launchpad/index.js")],
},
output: {
path: path.join(__dirname, "assets/build"),
filename: "[name].js",
publicPath: "/assets/build"
}
};
if (isFirefoxPanel()) {
// Just use the entrypoint in the panel
webpackConfig.entry.reps = path.join(projectPath, "index.js");
// export via commonjs2 `module.exports`
webpackConfig.output.libraryTarget = "umd";
}
webpackConfig.resolve = {
alias: {
"devtools/client/shared/vendor/react": "react",
"devtools/client/shared/vendor/react-dom": "react-dom",
"devtools/client/shared/vendor/react-dom-factories": "react-dom-factories",
"devtools/client/shared/vendor/react-prop-types": "prop-types",
"Services": path.join(__dirname,
"node_modules/devtools-modules/client/shared/shim/Services"),
}
};
const extra = {};
webpackConfig.plugins = [new ObjectRestSpreadPlugin()];
if (!isDevelopment()) {
webpackConfig.output.libraryTarget = "umd";
extra.excludeMap = {
react: "devtools/client/shared/vendor/react",
"react-dom": "devtools/client/shared/vendor/react-dom",
"react-dom-factories": "devtools/client/shared/vendor/react-dom-factories",
"react-redux": "devtools/client/shared/vendor/react-redux",
"redux": "devtools/client/shared/vendor/redux",
"prop-types": "devtools/client/shared/vendor/react-prop-types",
lodash: "devtools/client/shared/vendor/lodash",
};
}
const envConfig = getConfig();
module.exports = toolboxConfig(webpackConfig, envConfig, extra);