-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathwebpack.config.js
65 lines (61 loc) · 1.41 KB
/
webpack.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
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
const path = require("path");
const nodeExternals = require("webpack-node-externals"); // Import webpack-node-externals
const TerserPlugin = require("terser-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
module.exports = {
mode: "production",
entry: "./server.js",
output: {
path: path.join(__dirname, "build"),
publicPath: "/",
filename: "www/server.js",
clean: true,
},
target: "node",
node: false, // Disable built-in Node.js polyfills
externals: [
nodeExternals(), // Exclude external modules
],
optimization: {
minimize: true,
minimizer: [new TerserPlugin({
terserOptions: {
compress: {
// drop_console: true,
drop_debugger: true,
},
},
exclude: /\/utils/,
})],
},
module: {
rules: [
// {
// test: /\.node$/,
// loader: "node-loader",
// },
{
test: /\.js$/,
loader: "babel-loader",
},
// Add Babel loaders and presets if needed
],
},
plugins: [
new CopyWebpackPlugin({
patterns: [{
from: "utils", // Source directory (contains env and key files)
to: "www/utils", // Target directory inside the build output
},
{
from: "package.json", // Source file (package.json)
to: "package.json", // Target file inside the build output
},
{
from: "package-lock.json", // Source file (package-lock.json)
to: "package-lock.json", // Target file inside the build output
},
],
}),
]
};