-
Notifications
You must be signed in to change notification settings - Fork 16
/
webpack.config.ts
87 lines (81 loc) · 2 KB
/
webpack.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
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'),
}
})
],
infrastructureLogging: {
level: 'log', // enables logging required for problem matchers
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [{ loader: 'ts-loader' }],
},
{
test: /\.m?js/,
resolve: {
fullySpecified: false
}
}
],
}
}
const rendererConfig: Configuration = {
...baseConfig,
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'
}
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]