-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
vite.config.js
71 lines (68 loc) · 2.13 KB
/
vite.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import { defineConfig } from 'vite';
import { svelte } from '@sveltejs/vite-plugin-svelte';
import sveltePreprocess from 'svelte-preprocess';
import { readdirSync } from 'fs';
import { join } from 'path';
import config from './package.json';
const ignoreWarnings = new Set([
'a11y-no-onchange',
'a11y-label-has-associated-control',
'a11y-mouse-events-have-key-events',
'a11y-mouse-events-have-key-events',
]);
// eslint-disable-next-line @typescript-eslint/no-var-requires
// const config = require('./package.json');
export default defineConfig(({ mode }) => {
console.log('defineConfig', mode);
const locales = readdirSync(join('src', 'i18n'))
.filter((s) => s.endsWith('.json'))
.map((s) => s.replace('.json', ''));
const production = mode === 'production';
console.log('mode', mode);
return {
root: './src',
base: './', // use relative paths
publicDir: '../public',
clearScreen: false,
server: {
port: 3000,
strictPort: true,
},
resolve: {
alias: {
'mapbox-gl': 'maplibre-gl',
},
},
optimizeDeps: {
include: ['highlight.js', 'highlight.js/lib/core'],
},
// to make use of `TAURI_PLATFORM`, `TAURI_ARCH`, `TAURI_FAMILY`, `TAURI_PLATFORM_VERSION`, `TAURI_PLATFORM_TYPE` and `TAURI_DEBUG` env variables
envPrefix: ['VITE_', 'TAURI_'],
build: {
outDir: '../build',
emptyOutDir: true,
// tauri supports es2021
target: ['es2021', 'chrome97', 'safari13'],
// don't minify for debug builds
minify: !process.env.TAURI_DEBUG && 'esbuild',
// produce sourcemaps for debug builds
sourcemap: !!process.env.TAURI_DEBUG,
},
plugins: [
svelte({
onwarn(warning, defaultHandler) {
// don't warn on <marquee> elements, cos they're cool
if (ignoreWarnings.has(warning.code)) return;
// handle all other warnings normally
defaultHandler(warning);
},
preprocess: sveltePreprocess(),
}),
],
define: {
SUPPORTED_LOCALES: JSON.stringify(locales),
REPO_URL: `"${config.homepage}"`,
PRODUCTION: production,
},
};
});