|
1 | 1 | import esbuild from 'esbuild';
|
2 |
| -import process from 'process'; |
3 | 2 | import builtins from 'builtin-modules';
|
4 | 3 | import esbuildSvelte from 'esbuild-svelte';
|
5 | 4 | import sveltePreprocess from 'svelte-preprocess';
|
| 5 | +import manifest from './manifest.json' assert { type: 'json' }; |
6 | 6 |
|
7 | 7 | const banner = `/*
|
| 8 | +------------------------------------------- |
| 9 | +${manifest.name} - Release Build |
| 10 | +------------------------------------------- |
| 11 | +By: ${manifest.author} (${manifest.authorUrl}) |
| 12 | +Time: ${new Date().toUTCString()} |
| 13 | +Version: ${manifest.version} |
| 14 | +------------------------------------------- |
8 | 15 | THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
|
9 | 16 | if you want to view the source, please visit the github repository of this plugin
|
10 | 17 | */
|
11 | 18 | `;
|
12 | 19 |
|
13 |
| -const prod = process.argv[2] === 'production'; |
14 |
| - |
15 |
| -esbuild |
16 |
| - .build({ |
17 |
| - banner: { |
18 |
| - js: banner, |
19 |
| - }, |
20 |
| - entryPoints: ['src/main.ts'], |
21 |
| - bundle: true, |
22 |
| - external: [ |
23 |
| - 'obsidian', |
24 |
| - 'electron', |
25 |
| - '@codemirror/autocomplete', |
26 |
| - '@codemirror/closebrackets', |
27 |
| - '@codemirror/collab', |
28 |
| - '@codemirror/commands', |
29 |
| - '@codemirror/comment', |
30 |
| - '@codemirror/fold', |
31 |
| - '@codemirror/gutter', |
32 |
| - '@codemirror/highlight', |
33 |
| - '@codemirror/history', |
34 |
| - '@codemirror/language', |
35 |
| - '@codemirror/lint', |
36 |
| - '@codemirror/matchbrackets', |
37 |
| - '@codemirror/panel', |
38 |
| - '@codemirror/rangeset', |
39 |
| - '@codemirror/rectangular-selection', |
40 |
| - '@codemirror/search', |
41 |
| - '@codemirror/state', |
42 |
| - '@codemirror/stream-parser', |
43 |
| - '@codemirror/text', |
44 |
| - '@codemirror/tooltip', |
45 |
| - '@codemirror/view', |
46 |
| - ...builtins, |
47 |
| - ], |
48 |
| - format: 'cjs', |
49 |
| - watch: !prod, |
50 |
| - target: 'es2018', |
51 |
| - logLevel: 'info', |
52 |
| - sourcemap: prod ? false : 'inline', |
53 |
| - treeShaking: true, |
54 |
| - outfile: 'main.js', |
55 |
| - plugins: [ |
56 |
| - esbuildSvelte({ |
57 |
| - compilerOptions: { css: true }, |
58 |
| - preprocess: sveltePreprocess(), |
59 |
| - }), |
60 |
| - ], |
61 |
| - }) |
62 |
| - .catch(() => process.exit(1)); |
| 20 | +const build = await esbuild.build({ |
| 21 | + banner: { |
| 22 | + js: banner, |
| 23 | + }, |
| 24 | + entryPoints: ['src/main.ts'], |
| 25 | + bundle: true, |
| 26 | + external: [ |
| 27 | + 'obsidian', |
| 28 | + 'electron', |
| 29 | + '@codemirror/autocomplete', |
| 30 | + '@codemirror/collab', |
| 31 | + '@codemirror/commands', |
| 32 | + '@codemirror/language', |
| 33 | + '@codemirror/lint', |
| 34 | + '@codemirror/search', |
| 35 | + '@codemirror/state', |
| 36 | + '@codemirror/view', |
| 37 | + '@lezer/common', |
| 38 | + '@lezer/highlight', |
| 39 | + '@lezer/lr', |
| 40 | + ...builtins, |
| 41 | + ], |
| 42 | + format: 'cjs', |
| 43 | + target: 'es2018', |
| 44 | + logLevel: 'info', |
| 45 | + sourcemap: false, |
| 46 | + treeShaking: true, |
| 47 | + outfile: 'main.js', |
| 48 | + minify: true, |
| 49 | + metafile: true, |
| 50 | + plugins: [ |
| 51 | + esbuildSvelte({ |
| 52 | + compilerOptions: { css: 'injected' }, |
| 53 | + preprocess: sveltePreprocess(), |
| 54 | + filterWarnings: warning => { |
| 55 | + // we don't want warnings from node modules that we can do nothing about |
| 56 | + return !warning.filename.includes('node_modules'); |
| 57 | + }, |
| 58 | + }), |
| 59 | + ], |
| 60 | +}); |
0 commit comments