-
Notifications
You must be signed in to change notification settings - Fork 12
/
webpack.config.js
124 lines (117 loc) · 3.06 KB
/
webpack.config.js
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
120
121
122
123
124
//@ts-check
'use strict';
const path = require('path');
const webpack = require('webpack');
const packageJSON = require('./package.json')
const CopyPlugin = require('copy-webpack-plugin');
const envPlugin = new webpack.DefinePlugin({
'process.env.EXT_NAME': JSON.stringify('gitpod.gitpod-desktop'),
'process.env.EXT_VERSION': JSON.stringify(packageJSON.version ?? '0.0.1'),
'process.env.SEGMENT_KEY': JSON.stringify(packageJSON.segmentKey ?? ''),
});
/**@type {import('webpack').Configuration}*/
const prodConfig = {
target: 'node',
entry: {
extension: './src/extension.ts',
'local-ssh/proxy': './src/local-ssh/proxy.ts',
},
output: {
path: path.resolve(__dirname, 'out'),
filename: '[name].js',
libraryTarget: "commonjs2",
devtoolModuleFilenameTemplate: "../[resource-path]",
},
devtool: 'source-map',
externals: {
vscode: "commonjs vscode",
bufferutil: "bufferutil",
"utf-8-validate": "utf-8-validate",
"node-rsa": "node-rsa",
"@vscode/windows-ca-certs": "@vscode/windows-ca-certs"
},
resolve: {
mainFields: ['main'],
extensions: ['.ts', '.js']
},
module: {
rules: [{
test: /\.ts$/,
exclude: /node_modules/,
use: [{
loader: 'ts-loader'
}]
}]
},
plugins: [
new webpack.IgnorePlugin({
resourceRegExp: /crypto\/build\/Release\/sshcrypto\.node$/,
}),
new webpack.IgnorePlugin({
resourceRegExp: /cpu-features/,
}),
new webpack.IgnorePlugin({ contextRegExp: /node-fetch/, resourceRegExp: /^encoding$/ }),
new CopyPlugin({
patterns: [
{ from: 'src/local-ssh/proxylauncher.bat', to: 'local-ssh/proxylauncher.bat' },
{ from: 'src/local-ssh/proxylauncher.sh', to: 'local-ssh/proxylauncher.sh' },
],
}),
envPlugin,
]
}
/**@type {import('webpack').Configuration}*/
const devConfig = {
target: 'node',
entry: {
'local-ssh/proxy': './src/local-ssh/proxy.ts',
},
output: {
path: path.resolve(__dirname, 'out'),
filename: '[name].js',
libraryTarget: "commonjs2",
devtoolModuleFilenameTemplate: "../[resource-path]",
},
devtool: 'source-map',
externals: {
bufferutil: "bufferutil",
"utf-8-validate": "utf-8-validate",
"node-rsa": "node-rsa",
"@vscode/windows-ca-certs": "@vscode/windows-ca-certs"
},
resolve: {
mainFields: ['main'],
extensions: ['.ts', '.js']
},
module: {
rules: [{
test: /\.ts$/,
exclude: /node_modules/,
use: [{
loader: 'ts-loader'
}]
}]
},
plugins: [
new webpack.IgnorePlugin({ contextRegExp: /node-fetch/, resourceRegExp: /^encoding$/ }),
new CopyPlugin({
patterns: [
{ from: 'src/local-ssh/proxylauncher.bat', to: 'local-ssh/proxylauncher.bat' },
{ from: 'src/local-ssh/proxylauncher.sh', to: 'local-ssh/proxylauncher.sh' },
],
}),
envPlugin,
],
watchOptions: {
// for some systems, watching many files can result in a lot of CPU or memory usage
// https://webpack.js.org/configuration/watch/#watchoptionsignored
// don't use this pattern, if you have a monorepo with linked packages
ignored: /node_modules/,
},
}
module.exports = (_env, argv) => {
if (argv.mode === 'development') {
return devConfig;
}
return prodConfig;
};