|
1 | 1 | import { createRestPluginIfEnabled } from "./RestPlugin.js"; |
| 2 | + |
2 | 3 | export const Clean = process.env["Clean"] === "true"; |
3 | 4 | export const Meta = process.env["Meta"] === "true"; |
4 | | -export const On = process.env["NODE_ENV"] === "development" || |
5 | | - process.env["TAURI_ENV_DEBUG"] === "true"; |
| 5 | +export const On = |
| 6 | + process.env["NODE_ENV"] === "development" || |
| 7 | + process.env["TAURI_ENV_DEBUG"] === "true"; |
6 | 8 | /** |
7 | 9 | * @module ESBuild |
8 | 10 | * |
9 | 11 | */ |
10 | 12 | export default { |
11 | | - color: true, |
12 | | - format: "esm", |
13 | | - logLevel: On ? "debug" : "silent", |
14 | | - metafile: Meta, |
15 | | - minify: !On, |
16 | | - outdir: "Configuration", |
17 | | - platform: "node", |
18 | | - target: "esnext", |
19 | | - tsconfig: "tsconfig.json", |
20 | | - write: true, |
21 | | - legalComments: On ? "inline" : "none", |
22 | | - bundle: false, |
23 | | - assetNames: "Asset/[name]-[hash]", |
24 | | - sourcemap: On, |
25 | | - drop: On ? [] : ["debugger"], |
26 | | - ignoreAnnotations: !On, |
27 | | - keepNames: On, |
28 | | - plugins: [ |
29 | | - { |
30 | | - name: "Target", |
31 | | - // @ts-ignore |
32 | | - setup({ onStart, initialOptions: { outdir } }) { |
33 | | - switch (true) { |
34 | | - case Clean === true: |
35 | | - onStart(async () => { |
36 | | - try { |
37 | | - outdir |
38 | | - ? await (await import("node:fs/promises")).rm(outdir, { |
39 | | - recursive: true, |
40 | | - }) |
41 | | - : {}; |
42 | | - } |
43 | | - catch (_Error) { |
44 | | - console.log(_Error); |
45 | | - } |
46 | | - }); |
47 | | - break; |
48 | | - default: |
49 | | - break; |
50 | | - } |
51 | | - }, |
52 | | - }, |
53 | | - // Conditionally add Rest plugin when Compiler=Rest |
54 | | - ...(createRestPluginIfEnabled() ? [createRestPluginIfEnabled()] : []), |
55 | | - ].filter((plugin) => plugin !== null), |
56 | | - loader: { |
57 | | - ".json": "copy", |
58 | | - ".sh": "copy", |
59 | | - }, |
| 13 | + color: true, |
| 14 | + format: "esm", |
| 15 | + logLevel: On ? "debug" : "silent", |
| 16 | + metafile: Meta, |
| 17 | + minify: !On, |
| 18 | + outdir: "Configuration", |
| 19 | + platform: "node", |
| 20 | + target: "esnext", |
| 21 | + tsconfig: "tsconfig.json", |
| 22 | + write: true, |
| 23 | + legalComments: On ? "inline" : "none", |
| 24 | + bundle: false, |
| 25 | + assetNames: "Asset/[name]-[hash]", |
| 26 | + sourcemap: On, |
| 27 | + drop: On ? [] : ["debugger"], |
| 28 | + ignoreAnnotations: !On, |
| 29 | + keepNames: On, |
| 30 | + plugins: [ |
| 31 | + { |
| 32 | + name: "Target", |
| 33 | + // @ts-ignore |
| 34 | + setup({ onStart, initialOptions: { outdir } }) { |
| 35 | + switch (true) { |
| 36 | + case Clean === true: |
| 37 | + onStart(async () => { |
| 38 | + try { |
| 39 | + outdir |
| 40 | + ? await ( |
| 41 | + await import("node:fs/promises") |
| 42 | + ).rm(outdir, { |
| 43 | + recursive: true, |
| 44 | + }) |
| 45 | + : {}; |
| 46 | + } catch (_Error) { |
| 47 | + console.log(_Error); |
| 48 | + } |
| 49 | + }); |
| 50 | + break; |
| 51 | + default: |
| 52 | + break; |
| 53 | + } |
| 54 | + }, |
| 55 | + }, |
| 56 | + // Conditionally add Rest plugin when Compiler=Rest |
| 57 | + ...(createRestPluginIfEnabled() ? [createRestPluginIfEnabled()] : []), |
| 58 | + ].filter((plugin) => plugin !== null), |
| 59 | + loader: { |
| 60 | + ".json": "copy", |
| 61 | + ".sh": "copy", |
| 62 | + }, |
60 | 63 | }; |
61 | 64 | export const { sep, posix } = await import("node:path"); |
0 commit comments