This repository was archived by the owner on May 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwebpack.config.worker.ts
56 lines (53 loc) · 1.72 KB
/
webpack.config.worker.ts
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
import { CleanWebpackPlugin } from "clean-webpack-plugin";
import dotenv from "dotenv";
import * as path from "path";
import * as webpack from "webpack";
const dotEnvConfigs = {
path: path.resolve(process.cwd(), ".env"),
};
dotenv.config(dotEnvConfigs);
const config: webpack.Configuration = {
entry: {
service_worker: "./src/worker/start.worker.ts",
},
mode: `production`,
target: "node",
output: {
path: path.resolve(__dirname, "./dist/worker"), //! plz setup outDir in tsconfig.json if you want build many file, if you don't setup it, build export =1 file
filename: "index.js",
},
devtool: "inline-source-map",
module: {
rules: [
{
test: /\.ts?$/,
use: "ts-loader",
exclude: /node_modules/,
},
],
},
resolve: {
extensions: [".ts", ".js", ".tsx", ".json"],
},
optimization: {
minimize: true,
emitOnErrors: true,
mangleWasmImports: true,
removeAvailableModules: true, //? Set true when running in production
removeEmptyChunks: true,
mergeDuplicateChunks: true, //? Set true when running in production
},
plugins: [
new webpack.DefinePlugin({
"process.env": {
NODE_ENV: JSON.stringify(process.env.NODE_ENV),
RABBIT_URL: JSON.stringify(process.env.RABBIT_URL),
REDIS_URL: JSON.stringify(process.env.REDIS_URL),
DB_URL: JSON.stringify(process.env.DB_URL),
PORT: JSON.stringify(process.env.PORT),
},
}),
new CleanWebpackPlugin({ cleanStaleWebpackAssets: true, dry: true }),
],
};
export default config;