Skip to content

Commit 5360c84

Browse files
committed
Merge branch 'johan/webpack'
2 parents 29e7b50 + 45d8cc9 commit 5360c84

File tree

6 files changed

+2017
-74
lines changed

6 files changed

+2017
-74
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
/out/
2+
/dist/
23
/node_modules/
34
/.vscode-test/
45
/git-commit-message-plus-99.99.99.vsix

.vscodeignore

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,13 @@
22
.vscode-test/**
33
**/*.blend*
44
**/test*/
5+
6+
# Source:
7+
# https://code.visualstudio.com/api/working-with-extensions/bundling-extension#publishing
8+
.vscode
9+
node_modules
10+
out/
11+
src/
12+
tsconfig.json
13+
webpack.config.js
14+
esbuild.js

esbuild.js

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
const esbuild = require('esbuild');
2+
3+
const production = process.argv.includes('--production');
4+
const watch = process.argv.includes('--watch');
5+
6+
async function main() {
7+
const ctx = await esbuild.context({
8+
entryPoints: ['src/extension.ts'],
9+
bundle: true,
10+
format: 'cjs',
11+
minify: production,
12+
sourcemap: !production,
13+
sourcesContent: false,
14+
platform: 'node',
15+
outfile: 'dist/extension.js',
16+
external: ['vscode'],
17+
logLevel: 'warning',
18+
plugins: [
19+
/* add to the end of plugins array */
20+
esbuildProblemMatcherPlugin
21+
]
22+
});
23+
if (watch) {
24+
await ctx.watch();
25+
} else {
26+
await ctx.rebuild();
27+
await ctx.dispose();
28+
}
29+
}
30+
31+
/**
32+
* @type {import('esbuild').Plugin}
33+
*/
34+
const esbuildProblemMatcherPlugin = {
35+
name: 'esbuild-problem-matcher',
36+
37+
setup(build) {
38+
build.onStart(() => {
39+
console.log('[watch] build started');
40+
});
41+
build.onEnd(result => {
42+
result.errors.forEach(({ text, location }) => {
43+
console.error(`✘ [ERROR] ${text}`);
44+
if (location == null) return;
45+
console.error(` ${location.file}:${location.line}:${location.column}:`);
46+
});
47+
console.log('[watch] build finished');
48+
});
49+
}
50+
};
51+
52+
main().catch(e => {
53+
console.error(e);
54+
process.exit(1);
55+
});

0 commit comments

Comments
 (0)