-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathesbuild.js
More file actions
135 lines (124 loc) · 3.58 KB
/
esbuild.js
File metadata and controls
135 lines (124 loc) · 3.58 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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
const esbuild = require("esbuild");
const production = process.argv.includes('--production');
const watch = process.argv.includes('--watch');
/**
* @type {import('esbuild').Plugin}
*/
const extensionEsbuildProblemMatcherPlugin = {
name: 'extension-esbuild-problem-matcher',
setup(build) {
build.onStart(() => {
console.log('[watch] build started');
});
build.onEnd((result) => {
result.errors.forEach(({ text, location }) => {
console.error(`✘ [ERROR] ${text}`);
console.error(` ${location.file}:${location.line}:${location.column}:`);
});
console.log('[watch] build finished');
});
},
};
const browserEsbuildProblemMatcherPlugin = {
name: 'browser-esbuild-problem-matcher',
setup(build) {
build.onStart(() => {
console.log('[browser-watch] build started');
});
build.onEnd((result) => {
result.errors.forEach(({ text, location }) => {
console.error(`✘ [ERROR] ${text}`);
console.error(` ${location.file}:${location.line}:${location.column}:`);
});
console.log('[browser-watch] build finished');
});
},
};
async function main() {
const extensionCtx = await esbuild.context({
entryPoints: [
'src/extension.ts'
],
bundle: true,
format: 'cjs',
minify: production,
sourcemap: !production,
sourcesContent: false,
platform: 'node',
outfile: 'dist/extension.js',
external: ['vscode', 'NeteaseCloudMusicApi'],
logLevel: 'silent',
plugins: [extensionEsbuildProblemMatcherPlugin],
});
const browserCtx = await esbuild.context({
entryPoints: [
'src/extensions/markdown-md/ui/mermaidPreview.ts',
'src/extensions/markdown-mdx/ui/mdxPreviewWebview.ts',
'src/extensions/git-better/gitlab-panel/panels/header/header.ts',
'src/extensions/git-better/gitlab-panel/panels/graphics-top/graphics.ts',
'src/extensions/git-better/gitlab-panel/panels/stats-left/stats.ts',
'src/extensions/git-better/gitlab-panel/panels/commits-center/commits.ts',
'src/extensions/git-better/gitlab-panel/panels/inspect-right/inspect.ts',
'src/extensions/screenshot-code/ui/webview.ts',
'src/extensions/screenshot-code/ui/styles.css',
'src/extensions/focus/screens/atm-data/screenshot/ui/index.ts'
],
bundle: true,
format: 'iife',
minify: production,
sourcemap: !production,
sourcesContent: false,
platform: 'browser',
target: ['es2020'],
outdir: 'dist',
entryNames: '[name]',
logLevel: 'silent',
plugins: [browserEsbuildProblemMatcherPlugin],
});
const focusWebviewCtx = await esbuild.context({
entryPoints: ['src/extensions/focus/view/ui/index.ts'],
bundle: true,
format: 'iife',
minify: production,
sourcemap: !production,
sourcesContent: false,
platform: 'browser',
outfile: 'dist/atm-music-webview.js',
logLevel: 'silent',
plugins: [browserEsbuildProblemMatcherPlugin],
});
const serverCtx = await esbuild.context({
entryPoints: [
'src/extensions/atm-lint/server/lintServer.ts'
],
bundle: true,
format: 'cjs',
minify: production,
sourcemap: !production,
sourcesContent: false,
platform: 'node',
outfile: 'dist/lintServer.js',
external: ['vscode'],
logLevel: 'silent',
plugins: [extensionEsbuildProblemMatcherPlugin],
});
if (watch) {
await extensionCtx.watch();
await browserCtx.watch();
await focusWebviewCtx.watch();
await serverCtx.watch();
} else {
await extensionCtx.rebuild();
await extensionCtx.dispose();
await browserCtx.rebuild();
await browserCtx.dispose();
await focusWebviewCtx.rebuild();
await focusWebviewCtx.dispose();
await serverCtx.rebuild();
await serverCtx.dispose();
}
}
main().catch(e => {
console.error(e);
process.exit(1);
});