-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
77 lines (70 loc) · 2.19 KB
/
vite.config.ts
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
72
73
74
75
76
77
import { sveltekit } from '@sveltejs/kit/vite';
import { configDefaults } from 'vitest/config';
import babel from 'vite-babel-plugin';
import macrosPlugin from 'vite-plugin-babel-macros';
import fs from 'fs';
import basicSsl from '@vitejs/plugin-basic-ssl';
import { loadEnv } from 'vite';
const pkg = JSON.parse(fs.readFileSync(new URL('package.json', import.meta.url), 'utf8'));
const externalPackages = ['qrcode'];
const NODE_ENV = process.env.NODE_ENV;
const dev = NODE_ENV === 'development';
const packages = Object.keys(pkg.dependencies || {}).filter((v) =>
dev ? true : externalPackages.includes(v) === false,
);
const localEnvVars = loadEnv('', process.cwd(), '');
const devPlugins =
dev && localEnvVars.VITE_SERVER_ADDRESS_OVERRIDE !== 'localhost' ? [basicSsl()] : [];
const enableSourceMaps = Boolean(
localEnvVars.UPLOAD_SOURCEMAPS === 'true' &&
localEnvVars.DATADOG_API_KEY,
);
console.log('enableSourceMaps', enableSourceMaps);
/** @type {import('vite').UserConfig} */
const config = {
build: {
assetsInlineLimit: 0,
sourcemap: enableSourceMaps ? 'hidden' : false,
},
optimizeDeps: {
include: [
...Object.keys(pkg.dependencies || {}),
'nanoid/non-secure',
'make-plural/plurals',
],
exclude: ['@urql/svelte' ],
},
plugins: [
...devPlugins,
babel.default(),
macrosPlugin(),
sveltekit(),
],
// Vite seems to have some issues resolving the unpic package during local dev.
// Manual resolving this package seems to fix it for now.
// Will need further investigation as to why this is happening.
resolve: {
alias: {
'@unpic/svelte': '/node_modules/@unpic/svelte',
},
},
server: {
fs: {
//Allow serving files from one level up to the project root
allow: ['./', '../'],
},
proxy: {}, // Workaround for the issue raised here: https://github.com/sveltejs/kit/issues/11365
// maxSessionMemory: 1000,
},
ssr: dev ? { noExternal: ['svelte-markdown'], external: packages } : { noExternal: packages },
test: {
exclude: [
...configDefaults.exclude,
'packages/template/*',
'**/playwright/**',
'**/cms/**',
'**/src/games/machine/**',
],
},
};
export default config;