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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
|
/* 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 CopyWebpackPlugin = require("copy-webpack-plugin");
const webpack = require("webpack");
const ExtractTextPlugin = require("extract-text-webpack-plugin");
const mozillaCentralMappings = require("./configs/mozilla-central-mappings");
const path = require("path");
const ObjectRestSpreadPlugin = require("@sucrase/webpack-object-rest-spread-plugin");
/*
* builds a path that's relative to the project path
* returns an array so that we can prepend
* hot-module-reloading in local development
*/
function getEntry(filename) {
return [path.join(__dirname, filename)];
}
module.exports = {
context: path.resolve(__dirname, "src"),
devtool: false,
node: { fs: "empty" },
recordsPath: path.join(__dirname, "bin/module-manifest.json"),
entry: {
vendors: getEntry("src/vendors.js"),
},
output: {
path: process.env.OUTPUT_PATH,
filename: "[name].js",
publicPath: "/assets/build",
libraryTarget: "umd",
},
plugins: [
new webpack.BannerPlugin({
banner: `/* 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/. */
`,
raw: true,
}),
new ObjectRestSpreadPlugin(),
new ExtractTextPlugin("[name].css"),
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify(process.env.NODE_ENV || "production"),
},
}),
],
module: {
rules: [
{
test: /\.json$/,
loader: "json-loader",
},
{
test: /\.js$/,
exclude: request => {
// Some paths are excluded from Babel
const excludedPaths = ["fs", "node_modules"];
const excludedRe = new RegExp(`(${excludedPaths.join("|")})`);
const excluded = !!request.match(excludedRe);
const included = ["devtools-", "react-aria-components"];
const reincludeRe = new RegExp(
`node_modules(\\/|\\\\)${included.join("|")}`
);
return excluded && !request.match(reincludeRe);
},
loader: require.resolve("babel-loader"),
options: {
ignore: ["src/lib"],
},
},
{
test: /\.properties$/,
loader: "raw-loader",
},
// Extract CSS into a single file
{
test: /\.css$/,
use: ExtractTextPlugin.extract({
filename: "*.css",
use: [
{
loader: "css-loader",
options: {
importLoaders: 1,
url: false,
},
},
],
}),
},
],
},
externals: [
function externalsTest(context, mod, callback) {
// Any matching paths here won't be included in the bundle.
if (mozillaCentralMappings[mod]) {
callback(null, mozillaCentralMappings[mod]);
return;
}
callback();
},
],
};
|