Browse Source

added webpack.js

master
Daniel Hübleitner 4 years ago
parent
commit
e3f09335d8
2 changed files with 168 additions and 0 deletions
  1. 67
    0
      src/webpack.js
  2. 101
    0
      test/webpack.js

+ 67
- 0
src/webpack.js View File

@@ -0,0 +1,67 @@
1
+const path = require('path');
2
+const TerserPlugin = require('terser-webpack-plugin');
3
+
4
+
5
+const frontendConf = {
6
+  mode: 'production',
7
+  target: "web",
8
+  entry: path.resolve(__dirname, 'src', 'Frontend.ts'),
9
+  output: {
10
+      path: path.resolve(__dirname, 'lib'),
11
+      filename: "Frontend.js",
12
+      libraryTarget: 'commonjs',
13
+  },
14
+  module: {
15
+    rules: [
16
+      { test: /\.ts?$/, loader: "ts-loader" }
17
+    ]
18
+  },
19
+  resolve: {
20
+    extensions: [".ts", ".tsx", ".js"]
21
+  },
22
+  optimization: {
23
+    minimize: true,
24
+    minimizer: [
25
+      new TerserPlugin({
26
+        parallel: true,
27
+        exclude: [
28
+          /\.\/(.*)\/.ts/,
29
+          /\.\/(.*).ts/,
30
+        ],
31
+      }),
32
+    ],
33
+  },
34
+}
35
+
36
+const backendConf = {
37
+mode: 'production',
38
+target: "node",
39
+entry: path.resolve(__dirname, 'src', 'Backend.ts'),
40
+output: {
41
+    path: path.resolve(__dirname, 'lib'),
42
+    filename: "Backend.js",
43
+    libraryTarget: 'commonjs',
44
+},
45
+module: {
46
+  rules: [
47
+    { test: /\.ts?$/, loader: "ts-loader" }
48
+  ]
49
+},
50
+resolve: {
51
+  extensions: [".ts", ".tsx", ".js"]
52
+},
53
+optimization: {
54
+  minimize: true,
55
+  minimizer: [
56
+    new TerserPlugin({
57
+      parallel: true,
58
+      exclude: [
59
+        /\.\/(.*)\/.ts/,
60
+        /\.\/(.*).ts/,
61
+      ],
62
+    }),
63
+  ],
64
+},
65
+}
66
+
67
+module.exports = [frontendConf, backendConf]

+ 101
- 0
test/webpack.js View File

@@ -0,0 +1,101 @@
1
+const path = require('path');
2
+const TerserPlugin = require('terser-webpack-plugin');
3
+
4
+
5
+const frontendConf = {
6
+  mode: 'production',
7
+  target: "web",
8
+  output: {
9
+      path: path.resolve(__dirname, 'lib'),
10
+      libraryTarget: 'commonjs',
11
+  },
12
+  module: {
13
+    rules: [
14
+      { test: /\.ts?$/, loader: "ts-loader" }
15
+    ]
16
+  },
17
+  resolve: {
18
+    extensions: [".ts", ".tsx", ".js"]
19
+  },
20
+  optimization: {
21
+    minimize: true,
22
+    minimizer: [
23
+      new TerserPlugin({
24
+        parallel: true,
25
+        exclude: [
26
+          /\.\/(.*)\/.ts/,
27
+          /\.\/(.*).ts/,
28
+        ],
29
+      }),
30
+    ],
31
+  },
32
+}
33
+
34
+const backendConf = {
35
+mode: 'production',
36
+target: "node",
37
+output: {
38
+    path: path.resolve(__dirname, 'lib'),
39
+    libraryTarget: 'commonjs',
40
+},
41
+module: {
42
+  rules: [
43
+    { test: /\.ts?$/, loader: "ts-loader" }
44
+  ]
45
+},
46
+resolve: {
47
+  extensions: [".ts", ".tsx", ".js"]
48
+},
49
+optimization: {
50
+  minimize: true,
51
+  minimizer: [
52
+    new TerserPlugin({
53
+      parallel: true,
54
+      exclude: [
55
+        /\.\/(.*)\/.ts/,
56
+        /\.\/(.*).ts/,
57
+      ],
58
+    }),
59
+  ],
60
+},
61
+}
62
+
63
+const clientConf = {
64
+  ...frontendConf, 
65
+  ...{
66
+    entry: path.resolve(__dirname, 'src', 'Client.ts'),
67
+    output: {
68
+      filename: 'Frontend.js',
69
+    }
70
+  }
71
+}
72
+const clientTestConf = {
73
+  ...frontendConf, 
74
+  ...{
75
+    entry: path.resolve(__dirname, 'test', 'TestClient.ts'),
76
+    output: {
77
+      filename: 'TestFrontend.js',
78
+    }
79
+  } 
80
+}
81
+
82
+const serverConf = {
83
+  ...backendConf, 
84
+  ...{
85
+    entry: path.resolve(__dirname, 'src', 'Server.ts'),
86
+    output: {
87
+      filename: 'Backend.js',
88
+    }
89
+  }
90
+}
91
+const serverTestConf = {
92
+  ...backendConf, 
93
+  ...{
94
+    entry: path.resolve(__dirname, 'test', 'TestServer.ts'),
95
+    output: {
96
+      filename: 'TestBackend.js',
97
+    }
98
+  } 
99
+}
100
+
101
+module.exports = [clientConf, clientTestConf, serverConf, serverTestConf]

Loading…
Cancel
Save