Skip to content

Commit 3818c4d

Browse files
committed
Add webpack watch config
1 parent a04ade1 commit 3818c4d

File tree

6 files changed

+120
-19
lines changed

6 files changed

+120
-19
lines changed

.vscode/launch.json

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,7 @@
1212
"outFiles": [
1313
"${workspaceFolder}/out/**/*.js"
1414
],
15-
"preLaunchTask": "npm: watch",
16-
"env": {
17-
"TEST": "1",
18-
}
19-
}
15+
"preLaunchTask": "watch"
16+
},
2017
]
2118
}

.vscode/tasks.json

Lines changed: 58 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
"tasks": [
44
{
55
"type": "npm",
6-
"script": "watch",
6+
"script": "watch-ext",
7+
"label": "watch-ext",
78
"problemMatcher": "$tsc-watch",
89
"isBackground": true,
910
"presentation": {
@@ -13,6 +14,61 @@
1314
"kind": "build",
1415
"isDefault": true
1516
}
16-
}
17+
},
18+
{
19+
"type": "npm",
20+
"script": "watch-proxy",
21+
"label": "watch-proxy",
22+
"problemMatcher": {
23+
"owner": "typescript",
24+
// "applyTo": "closedDocuments",
25+
"source": "ts",
26+
"fileLocation": "absolute",
27+
"severity": "error",
28+
"pattern": [
29+
{
30+
"regexp": "\\[tsl\\] (ERROR|WARNING) in (.*)?\\((\\d+),(\\d+)\\)",
31+
"severity": 1,
32+
"file": 2,
33+
"line": 3,
34+
"column": 4
35+
},
36+
{
37+
"regexp": "\\s*TS(\\d+):\\s*(.*)$",
38+
"code": 1,
39+
"message": 2
40+
}
41+
],
42+
"background": {
43+
"activeOnStart": true,
44+
"beginsPattern": {
45+
"regexp": "[Cc]ompiling.*?|[Cc]ompil(ation|er) .*?starting"
46+
},
47+
"endsPattern": {
48+
"regexp": "[Cc]ompiled (.*?successfully|with .*?(error|warning))|[Cc]ompil(ation|er) .*?finished"
49+
}
50+
}
51+
},
52+
"isBackground": true,
53+
"presentation": {
54+
"reveal": "never"
55+
},
56+
"group": {
57+
"kind": "build",
58+
"isDefault": true
59+
}
60+
},
61+
{
62+
"label": "watch",
63+
"dependsOn": [
64+
"watch-ext",
65+
"watch-proxy"
66+
],
67+
"group": {
68+
"kind": "build",
69+
"isDefault": true
70+
},
71+
"problemMatcher": []
72+
},
1773
]
1874
}

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,9 +133,10 @@
133133
"configcatKey": "gitpod",
134134
"scripts": {
135135
"vscode:prepublish": "webpack --mode production",
136-
"webpack": "webpack --mode development",
137-
"compile": "tsc -b",
138-
"watch": "tsc -b -w",
136+
"compile-proxy": "webpack --mode development",
137+
"watch-proxy": "webpack watch --mode development",
138+
"compile-ext": "tsc -b",
139+
"watch-ext": "tsc -b -w",
139140
"package": "vsce package --yarn",
140141
"lint": "eslint . --ext .ts",
141142
"test": "mocha -u tdd",

src/services/localSSHService.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,12 +53,6 @@ export class LocalSSHService extends Disposable implements ILocalSSHService {
5353
}
5454

5555
private async initialize() {
56-
if (this.context.extensionMode !== vscode.ExtensionMode.Production) {
57-
// TODO: add webpack config for client.js in development, for now copy manually
58-
this.isSupportLocalSSH = true;
59-
return;
60-
}
61-
6256
try {
6357
const locations = await this.copyProxyScript();
6458
await this.configureSettings(locations);

tsconfig.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,5 +43,6 @@
4343
"exclude": [
4444
"node_modules",
4545
".vscode-test",
46+
"src/**/local-ssh/*"
4647
]
4748
}

webpack.config.js

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,10 @@ const CopyPlugin = require('copy-webpack-plugin');
99

1010
const daemonVersion = new webpack.DefinePlugin({
1111
'process.env.DAEMON_VERSION': JSON.stringify(packageJSON.daemonVersion ?? '0.0.1'),
12-
'process.env.DAEMON_EXTENSION_VERSION': JSON.stringify(packageJSON.version),
1312
});
1413

1514
/**@type {import('webpack').Configuration}*/
16-
const config = {
15+
const prodConfig = {
1716
target: 'node',
1817
entry: {
1918
extension: './src/extension.ts',
@@ -61,4 +60,57 @@ const config = {
6160
]
6261
}
6362

64-
module.exports = config;
63+
/**@type {import('webpack').Configuration}*/
64+
const devConfig = {
65+
target: 'node',
66+
entry: {
67+
'local-ssh/proxy': './src/local-ssh/proxy.ts',
68+
},
69+
output: {
70+
path: path.resolve(__dirname, 'out'),
71+
filename: '[name].js',
72+
libraryTarget: "commonjs2",
73+
devtoolModuleFilenameTemplate: "../[resource-path]",
74+
},
75+
devtool: 'source-map',
76+
externals: {
77+
bufferutil: "bufferutil",
78+
"utf-8-validate": "utf-8-validate",
79+
"node-rsa": "node-rsa"
80+
},
81+
resolve: {
82+
extensions: ['.ts', '.js']
83+
},
84+
module: {
85+
rules: [{
86+
test: /\.ts$/,
87+
exclude: /node_modules/,
88+
use: [{
89+
loader: 'ts-loader'
90+
}]
91+
}]
92+
},
93+
plugins: [
94+
new CopyPlugin({
95+
patterns: [
96+
{ from: 'src/local-ssh/proxylauncher.bat', to: 'local-ssh/proxylauncher.bat' },
97+
{ from: 'src/local-ssh/proxylauncher.sh', to: 'local-ssh/proxylauncher.sh' },
98+
],
99+
}),
100+
daemonVersion,
101+
],
102+
watchOptions: {
103+
// for some systems, watching many files can result in a lot of CPU or memory usage
104+
// https://webpack.js.org/configuration/watch/#watchoptionsignored
105+
// don't use this pattern, if you have a monorepo with linked packages
106+
ignored: /node_modules/,
107+
},
108+
}
109+
110+
module.exports = (_env, argv) => {
111+
if (argv.mode === 'development') {
112+
return devConfig;
113+
}
114+
115+
return prodConfig;
116+
};

0 commit comments

Comments
 (0)