annotate esbuild.config.mjs @ 19:2a9e941c96ee

Bring new build tools from the sample plugin project
author Ludovic Chabant <ludovic@chabant.com>
date Fri, 18 Mar 2022 19:19:18 -0700
parents 7975d7c73f8a
children 61fd7dde51d3
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
1 import esbuild from "esbuild";
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
2 import process from "process";
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
3 import builtins from 'builtin-modules'
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
4
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
5 const banner =
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
6 `/*
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
7 THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
8 if you want to view the source, please visit the github repository of this plugin
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
9 */
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
10 `;
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
11
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
12 const prod = (process.argv[2] === 'production');
19
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
13 const outdir = (process.argv[2] === 'dogfood' ? process.argv[3] : '');
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
14
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
15 const dirsep = (outdir.slice(-1) == '/' || outdir.slice(-1) == "\\") ? '' : '/';
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
16 const outfile = outdir + dirsep + 'main.js';
0
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
17
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
18 esbuild.build({
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
19 banner: {
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
20 js: banner,
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
21 },
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
22 entryPoints: ['src/main.ts'],
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
23 bundle: true,
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
24 external: [
19
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
25 'obsidian',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
26 'electron',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
27 '@codemirror/autocomplete',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
28 '@codemirror/closebrackets',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
29 '@codemirror/collab',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
30 '@codemirror/commands',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
31 '@codemirror/comment',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
32 '@codemirror/fold',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
33 '@codemirror/gutter',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
34 '@codemirror/highlight',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
35 '@codemirror/history',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
36 '@codemirror/language',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
37 '@codemirror/lint',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
38 '@codemirror/matchbrackets',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
39 '@codemirror/panel',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
40 '@codemirror/rangeset',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
41 '@codemirror/rectangular-selection',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
42 '@codemirror/search',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
43 '@codemirror/state',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
44 '@codemirror/stream-parser',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
45 '@codemirror/text',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
46 '@codemirror/tooltip',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
47 '@codemirror/view',
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
48 ...builtins],
0
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
49 format: 'cjs',
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
50 watch: !prod,
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
51 target: 'es2016',
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
52 logLevel: "info",
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
53 sourcemap: prod ? false : 'inline',
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
54 treeShaking: true,
19
2a9e941c96ee Bring new build tools from the sample plugin project
Ludovic Chabant <ludovic@chabant.com>
parents: 0
diff changeset
55 outfile: outfile,
0
7975d7c73f8a Initial commit
Ludovic Chabant <ludovic@chabant.com>
parents:
diff changeset
56 }).catch(() => process.exit(1));