-
Notifications
You must be signed in to change notification settings - Fork 30
Expand file tree
/
Copy pathwebpack.config.ts
More file actions
119 lines (113 loc) · 2.65 KB
/
webpack.config.ts
File metadata and controls
119 lines (113 loc) · 2.65 KB
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import path from 'node:path'
import ForkTsCheckerWebpackPlugin from 'fork-ts-checker-webpack-plugin'
import { Configuration, DefinePlugin } from 'webpack'
enum Mode {
PRODUCTION = 'production',
DEVELOPMENT = 'development'
}
const mode = process.env.NODE_ENV !== Mode.DEVELOPMENT
? Mode.PRODUCTION
: Mode.DEVELOPMENT
const testToken = 'globalThis._RUNME_TEST_TOKEN'
const baseConfig: Partial<Configuration> = {
mode,
devtool: 'source-map',
externals: {
vscode: 'commonjs vscode',
},
resolve: {
extensions: ['.ts', '.js']
},
plugins: [
new ForkTsCheckerWebpackPlugin({
typescript: {
configFile: path.join(__dirname, 'tsconfig.json'),
memoryLimit: 4096, // Allocate 2x the default memory limit
},
})
],
infrastructureLogging: {
level: 'log', // enables logging required for problem matchers
},
module: {
rules: [
{
test: /\.d\.ts$/,
type: 'asset/source',
generator: { emit: false },
},
{
test: /\.ts$/,
exclude: /node_modules/,
use: [{ loader: 'ts-loader' }],
},
{
test: /\.m?js/,
resolve: {
fullySpecified: false
}
}
],
}
}
const rendererConfig: Configuration = {
...baseConfig,
devtool: 'nosources-source-map',
entry: path.resolve('src', 'client', 'index.ts'),
experiments: { outputModule: true },
output: {
path: path.resolve(__dirname, 'out'),
filename: 'client.js',
libraryTarget: 'module',
chunkFormat: 'module'
},
target: 'web',
module: {
rules: [
{
test: /\.m?js/,
resolve: {
fullySpecified: false
}
},
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
options: {
transpileOnly: true,
compilerOptions: {
sourceMap: false,
}
}
}
],
}
]
}
}
const extensionConfig: Configuration = {
...baseConfig,
target: 'node',
entry: {
extension: path.resolve(__dirname, 'src', 'extension', 'index.ts'),
},
externals: ['vscode'],
output: {
path: path.resolve(__dirname, 'out'),
libraryTarget: 'commonjs2',
devtoolModuleFilenameTemplate: '../[resource-path]',
},
plugins: [
new DefinePlugin({
INSTRUMENTATION_KEY: JSON.stringify(process.env.INSTRUMENTATION_KEY || 'invalid'),
CONNECTION_STR: JSON.stringify(process.env.CONNECTION_STR || 'invalid'),
[testToken]: mode === Mode.DEVELOPMENT
? testToken
: 'false'
})
]
}
export default [extensionConfig, rendererConfig]