-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
webpack.web.config.ts
105 lines (102 loc) · 3.09 KB
/
webpack.web.config.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
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
100
101
102
103
104
105
import { Configuration, optimize } from "webpack";
import { resolve } from "path";
import { CleanWebpackPlugin } from "clean-webpack-plugin";
import { getConfigForTestScript, Mode, useEntrypoint } from "./webpack.config";
export default (env: Record<string, string | boolean>) => {
const mode = env.production === true ? "production" : "development";
return [
getConfigForWebWorkerExtension(mode),
getConfigForWebWorkerTests(mode),
getConfigForTestScript(mode),
];
};
export const getConfigForWebWorkerExtension = (mode: Mode): Configuration => {
return {
mode: mode,
target: "webworker",
name: "extension:webworker",
entry: useEntrypoint("webworker"),
output: {
filename: "extension.js",
libraryTarget: "commonjs2",
path: resolve(__dirname, "out", "extension", "web"),
},
devtool: "eval-source-map",
resolve: {
extensions: [".ts", "..."],
},
module: {
rules: [
{
test: /\.ts$/,
exclude: [/node_modules/, /\.node.ts$/],
use: {
loader: "ts-loader",
options: {
configFile: resolve(__dirname, "tsconfig.web.json"),
},
},
},
],
},
externals: {
vscode: "commonjs vscode",
},
plugins: [
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: ["extension.js"],
}),
new optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
],
};
};
export const getConfigForWebWorkerTests = (mode: Mode): Configuration => {
return {
mode: mode,
target: "webworker",
name: "tests:webworker",
entry: {
"test-runner": resolve(__dirname, "test/runner.web.ts"),
},
output: {
filename: "[name].js",
libraryTarget: "commonjs2",
path: resolve(__dirname, "out", "tests", "web"),
},
devtool: "eval-source-map",
resolve: {
extensions: [".ts", "..."],
},
module: {
exprContextCritical: false,
rules: [
{
test: /\.ts$/,
exclude: [/node_modules/, /\.node.ts$/],
use: {
loader: "ts-loader",
options: {
configFile: resolve(__dirname, "tsconfig.web.json"),
},
},
},
],
},
externals: {
vscode: "commonjs vscode",
},
plugins: [
new CleanWebpackPlugin({
cleanOnceBeforeBuildPatterns: ["test-runner.js"],
}),
new optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
],
performance: {
hints: false,
},
};
};