-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathwebpack.config.js
More file actions
79 lines (75 loc) · 1.78 KB
/
Copy pathwebpack.config.js
File metadata and controls
79 lines (75 loc) · 1.78 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
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
const { mergeWithRules } = require("webpack-merge");
const singleSpaDefaults = require("webpack-config-single-spa-react-ts");
const webpack = require("webpack");
const orgName = "chainbase-labs";
const projectName = "buildermaps-io";
module.exports = (webpackConfigEnv, argv) => {
const defaultConfig = singleSpaDefaults({
orgName,
projectName,
webpackConfigEnv,
argv,
});
return mergeWithRules({
externals: "replace",
module: {
rules: {
test: "match",
use: "replace",
},
},
})(defaultConfig, {
devServer: {
client: {
overlay: false,
},
},
module: {
rules: [
{
test: /\.css$/i,
use: [
"style-loader",
{
loader: "css-loader",
options: {
importLoaders: 1,
},
},
{
loader: "postcss-loader",
},
],
},
],
},
output: process.env.WEBPACK_SERVE
? {}
: {
filename: (pathData) => {
if (pathData.chunk.name === "main") {
return `${orgName}-${projectName}-main.[contenthash].js`;
}
return `${orgName}-${projectName}.[contenthash].js`;
},
clean: false,
},
externals: process.env.SHARED_MODULES?.replace(/^"|"$/g, "")
.split(",")
.filter((m) => m !== "single-spa")
.concat("react", "react-dom") || ["react", "react-dom"],
plugins: [
new webpack.ProvidePlugin({
process: "process",
}),
new webpack.DefinePlugin({
"process.env": JSON.stringify(process.env || {}),
}),
],
resolve: {
fallback: {
process: require.resolve("process"),
},
},
});
};