-
Notifications
You must be signed in to change notification settings - Fork 2
/
webpack.main.config.js
32 lines (29 loc) · 1.07 KB
/
webpack.main.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
const webpack = require("webpack");
const webpackCommonConfig = require("./webpack.common.config");
const { workers } = require("./webpack.workers.config");
const HtmlWebpackPlugin = require("html-webpack-plugin");
require("dotenv").config();
module.exports =
/** @param {import("webpack").Configuration} config */ function (config) {
if (config.mode === "production") {
for (const plugin of config.plugins) {
if (plugin instanceof webpack.BannerPlugin) {
plugin.options.exclude = /preload\.js$/i;
}
}
} else {
// add workers in dev
for (const plugin of config.plugins) {
if (plugin instanceof HtmlWebpackPlugin) {
plugin.options?.excludeChunks?.push(...Object.keys(workers));
}
}
if (config.entry) {
config.entry = {
...config.entry,
...workers,
};
}
}
return webpackCommonConfig(config);
};