-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.common.mjs
99 lines (97 loc) · 2.19 KB
/
webpack.common.mjs
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
// webpack.common.mjs
/*
SPDX-License-Identifier: CC-BY-4.0 OR GPL-3.0-or-later
This file is part of Network Engineering Pro
*/
import autoprefixer from "autoprefixer";
import path from "path";
import webpack from "webpack";
export default {
mode: "none", // Explicitly set the mode (overridden by merge)
entry: {
app: "./js/app.js",
},
output: {
path: path.resolve(process.cwd(), "dist"),
filename: "js/[name].[contenthash].js",
chunkFilename: "js/[name].[contenthash].js",
chunkFormat: "array-push",
clean: true,
},
target: "web",
module: {
rules: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
use: [
{
loader: "babel-loader",
options: {
presets: ["@babel/preset-env"],
cacheDirectory: true, // Enable caching for faster builds
},
},
"astroturf/loader",
],
},
{
test: /\.css$/,
use: [
"style-loader",
{
loader: "css-loader",
options: { modules: { auto: true } }, // Auto-detect CSS Modules
},
{
loader: "postcss-loader",
options: {
postcssOptions: {
plugins: [
autoprefixer({
add: true,
remove: false,
}),
],
},
},
},
],
},
],
},
optimization: {
usedExports: true,
sideEffects: false,
splitChunks: {
chunks: "all",
minSize: 20000,
maxSize: 100000, // Increased max chunk size
minChunks: 1,
cacheGroups: {
defaultVendors: {
test: /[\\/]node_modules[\\/]/,
name: "vendors",
priority: -10,
reuseExistingChunk: true,
},
default: {
minChunks: 2,
priority: -20,
reuseExistingChunk: true,
},
},
},
runtimeChunk: "single",
},
plugins: [
new webpack.ProvidePlugin({
global: "globalThis",
self: "globalThis",
window: "globalThis",
}),
],
resolve: {
extensions: [".js", ".json"],
},
};