Repository navigation
Expand file tree
/
Copy pathwebpack.config.js
More file actions
80 lines (77 loc) · 1.96 KB
/
Copy pathwebpack.config.js
File metadata and controls
80 lines (77 loc) · 1.96 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
80
const { withReact } = require("@nx/react");
const { composePlugins, withNx } = require("@nx/webpack");
function withSvgr() {
return (config) => {
const svgLoaderIndex = config.module.rules.findIndex(
(rule) =>
typeof rule === "object" && rule.test?.toString().includes("svg")
);
if (svgLoaderIndex !== -1) {
config.module.rules.splice(svgLoaderIndex, 1);
}
config.module.rules.push({
test: /\.svg$/,
use: [
{
loader: require.resolve("@svgr/webpack"),
options: {
exportType: "named",
namedExport: "ReactComponent",
ref: true,
svgo: false,
titleProp: true
}
}
]
});
return config;
};
}
module.exports = composePlugins(withNx(), withReact(), withSvgr(), (config) => {
config.experiments = {
...config.experiments,
outputModule: false
};
config.output.chunkFormat = "array-push";
config.output.chunkLoading = "jsonp";
config.output.module = false;
config.output.publicPath = "";
const htmlPlugin = config.plugins.find(
(plugin) => plugin.constructor.name === "HtmlWebpackPlugin"
);
if (htmlPlugin) {
htmlPlugin.options.scriptLoading = "defer";
htmlPlugin.userOptions.scriptLoading = "defer";
}
config.resolve.fallback = {
...config.resolve.fallback,
assert: require.resolve("assert/"),
child_process: false,
dgram: false,
dns: false,
fs: false,
http2: false,
module: false,
net: false,
stream: require.resolve("stream-browserify"),
tls: false,
url: require.resolve("url/")
};
config.module.rules.push({
test: /\.py$/i,
use: "raw-loader"
});
config.module.rules.unshift({
test: /\.worker\.ts$/i,
loader: "worker-loader",
options: {
inline: "no-fallback"
}
});
if (process.env.debug) {
require("fs-extra").writeJSONSync("./webpack.json", config, {
spaces: 2
});
}
return config;
});