-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathtsup.config.ts
56 lines (54 loc) · 1.47 KB
/
tsup.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
import { defineConfig } from 'tsup';
import polyfills from 'node-libs-browser';
const isProduction = process.env.NODE_ENV === 'production';
export default defineConfig([
{
entry: ['src/extension.ts'],
outDir: 'out',
external: ['vscode'],
noExternal: [/^(?!vscode$)/],
sourcemap: true,
loader: {
'.html': 'text',
},
minify: isProduction,
target: 'node16',
publicDir: 'ext',
},
{
entry: ['web/src/app.js'],
outDir: 'out',
noExternal: [/./],
outExtension: () => ({ js: '.js' }),
target: 'chrome102',
minify: isProduction,
format: 'iife',
sourcemap: true,
inject: ['web/polyfillShim.js'],
define: {
global: 'globalThis',
process: 'process',
Buffer: 'Buffer',
},
esbuildOptions(options) {
options.resolveExtensions = ['.mjs', '.js', '.ts'];
options.mainFields = ['browser', 'main'];
options.alias = {
...(options.alias || {}),
...Object.entries(polyfills)
.filter(([, modulePath]) => Boolean(modulePath))
.reduce((memo, [name, modulePath]) => {
memo[name] = modulePath;
return memo;
}, {}),
fs: './node_modules/browserify-fs',
'socket.io-client': './node_modules/socket.io-client/dist/socket.io.js',
vue: './node_modules/vue/dist/vue.esm.browser.js',
vuex: './node_modules/vuex/dist/vuex.esm.browser.js',
};
},
loader: {
'.html': 'text',
},
},
]);