|
4 | 4 | * |
5 | 5 | * SPDX-License-Identifier: MIT |
6 | 6 | */ |
7 | | -import { defineConfig } from 'vite'; |
| 7 | +import { defineConfig, loadEnv } from 'vite'; |
8 | 8 | import { svelte } from '@sveltejs/vite-plugin-svelte'; |
9 | 9 | import WindiCSS from 'vite-plugin-windicss'; |
10 | 10 | import { preprocessMeltUI, sequence } from '@melt-ui/pp'; |
11 | 11 | import { sveltePreprocess } from 'svelte-preprocess/dist/autoProcess'; |
12 | 12 | import Icons from 'unplugin-icons/vite'; |
13 | 13 |
|
14 | | -export default defineConfig({ |
15 | | - base: process.env.BASE_URL ?? '/', |
16 | | - plugins: [ |
17 | | - svelte({ |
18 | | - preprocess: sequence([sveltePreprocess({ typescript: true }), preprocessMeltUI()]), |
| 14 | +export default defineConfig(({ mode }) => { |
| 15 | + const commonEnv = loadEnv(mode, process.cwd(), ''); |
19 | 16 |
|
20 | | - onwarn(warning, defaultHandler) { |
21 | | - if (warning.code.includes('a11y')) return; // Ignores the a11y warnings when compiling. This does not apply to the editor, see comment at bottom for vscode instructions |
| 17 | + return { |
| 18 | + base: process.env.BASE_URL ?? '/', |
| 19 | + plugins: [ |
| 20 | + svelte({ |
| 21 | + preprocess: sequence([ |
| 22 | + sveltePreprocess({ typescript: true }), |
| 23 | + preprocessMeltUI(), |
| 24 | + ]), |
22 | 25 |
|
23 | | - // handle all other warnings normally |
24 | | - defaultHandler!(warning); |
| 26 | + onwarn(warning, defaultHandler) { |
| 27 | + if (warning.code.includes('a11y')) return; // Ignores the a11y warnings when compiling. This does not apply to the editor, see comment at bottom for vscode instructions |
| 28 | + |
| 29 | + // handle all other warnings normally |
| 30 | + defaultHandler!(warning); |
| 31 | + }, |
| 32 | + }), |
| 33 | + WindiCSS(), |
| 34 | + Icons({ compiler: 'svelte' }), |
| 35 | + ], |
| 36 | + define: { |
| 37 | + 'import.meta.env.VITE_APP_VERSION': JSON.stringify(process.env.npm_package_version), |
| 38 | + }, |
| 39 | + build: { |
| 40 | + target: 'es2017', |
| 41 | + rollupOptions: { |
| 42 | + input: 'index.html', |
25 | 43 | }, |
26 | | - }), |
27 | | - WindiCSS(), |
28 | | - Icons({ compiler: 'svelte' }), |
29 | | - ], |
30 | | - define: { |
31 | | - 'import.meta.env.VITE_APP_VERSION': JSON.stringify(process.env.npm_package_version), |
32 | | - }, |
33 | | - build: { |
34 | | - target: 'es2017', |
35 | | - rollupOptions: { |
36 | | - input: 'index.html', |
37 | 44 | }, |
38 | | - }, |
39 | | - test: { |
40 | | - globals: true, |
41 | | - setupFiles: ['./src/setup_tests.ts'], |
42 | | - poolOptions: { |
43 | | - threads: { |
44 | | - // threads disabled for now due to https://github.com/vitest-dev/vitest/issues/1982 |
45 | | - singleThread: true, |
| 45 | + server: commonEnv.API_PROXY |
| 46 | + ? { |
| 47 | + port: 5172, |
| 48 | + proxy: { |
| 49 | + '/api/v1': { |
| 50 | + target: commonEnv.API_PROXY, |
| 51 | + changeOrigin: true, |
| 52 | + }, |
| 53 | + }, |
| 54 | + } |
| 55 | + : undefined, |
| 56 | + test: { |
| 57 | + globals: true, |
| 58 | + setupFiles: ['./src/setup_tests.ts'], |
| 59 | + poolOptions: { |
| 60 | + threads: { |
| 61 | + // threads disabled for now due to https://github.com/vitest-dev/vitest/issues/1982 |
| 62 | + singleThread: true, |
| 63 | + }, |
46 | 64 | }, |
47 | 65 | }, |
48 | | - }, |
| 66 | + }; |
49 | 67 | }); |
50 | 68 |
|
51 | 69 | /** |
|
0 commit comments