diff options
Diffstat (limited to 'config/vite-common.js')
-rw-r--r-- | config/vite-common.js | 67 |
1 files changed, 0 insertions, 67 deletions
diff --git a/config/vite-common.js b/config/vite-common.js deleted file mode 100644 index 6b1d7c7..0000000 --- a/config/vite-common.js +++ /dev/null | |||
@@ -1,67 +0,0 @@ | |||
1 | // @ts-check | ||
2 | |||
3 | // `resolveJsonModule` is disabled for this package, but vite will load the json nevertheless. | ||
4 | // @ts-expect-error | ||
5 | import { chrome as chromeVersion, node as nodeVersion } from '../.electron-vendors.cache.json'; | ||
6 | |||
7 | /** @type {string} */ | ||
8 | const banner = `/*! | ||
9 | * Copyright (C) 2021-2022 Sophie contributors | ||
10 | * | ||
11 | * This file is part of Sophie. | ||
12 | * | ||
13 | * Sophie is free software: you can redistribute it and/or modify | ||
14 | * it under the terms of the GNU Affero General Public License as | ||
15 | * published by the Free Software Foundation, version 3. | ||
16 | * | ||
17 | * This program is distributed in the hope that it will be useful, | ||
18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
20 | * GNU Affero General Public License for more details. | ||
21 | * | ||
22 | * You should have received a copy of the GNU Affero General Public License | ||
23 | * along with this program. If not, see <https://www.gnu.org/licenses/>. | ||
24 | * | ||
25 | * SPDX-License-Identifier: AGPL-3.0-only | ||
26 | */ | ||
27 | `; | ||
28 | |||
29 | /** @type {string} */ | ||
30 | export const chrome = `chrome${chromeVersion}`; | ||
31 | |||
32 | /** @type {string} */ | ||
33 | export const node = `node${nodeVersion}`; | ||
34 | |||
35 | /** | ||
36 | * Extends a vite configuration with common options. | ||
37 | * | ||
38 | * @param {import('vite').UserConfig} config The configuration to extend. | ||
39 | * @return {import('vite').UserConfig} The configuration extended with common options. | ||
40 | */ | ||
41 | export function makeConfig(config) { | ||
42 | return { | ||
43 | mode: process.env.NODE, | ||
44 | envDir: process.cwd(), | ||
45 | ...config, | ||
46 | build: { | ||
47 | assetsDir: '.', | ||
48 | outDir: 'dist', | ||
49 | emptyOutDir: true, | ||
50 | sourcemap: true, | ||
51 | minify: process.env.MODE !== 'development', | ||
52 | brotliSize: false, | ||
53 | ...config.build, | ||
54 | lib: (typeof config.build.lib === 'object') ? { | ||
55 | fileName: (format) => format === 'cjs' ? 'index.cjs' : `index.${format}.js`, | ||
56 | ...config.build.lib, | ||
57 | } : undefined, | ||
58 | rollupOptions: { | ||
59 | ...config.build?.rollupOptions, | ||
60 | output: { | ||
61 | banner, | ||
62 | ...config.build?.rollupOptions?.output, | ||
63 | }, | ||
64 | }, | ||
65 | }, | ||
66 | }; | ||
67 | } | ||