-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.mjs
75 lines (64 loc) · 1.91 KB
/
vite.config.mjs
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
import { svelte } from '@sveltejs/vite-plugin-svelte';
import resolve from '@rollup/plugin-node-resolve'; // This resolves NPM modules from node_modules.
import preprocess from 'svelte-preprocess';
import { postcssConfig, terserConfig } from '@typhonjs-fvtt/runtime/rollup';
const s_PACKAGE_ID = 'modules/fates-descent';
const s_SVELTE_HASH_ID = 'fdcss';
const s_COMPRESS = false; // Set to true to compress the module bundle.
const s_SOURCEMAPS = true; // Generate sourcemaps for the bundle (recommended).
const s_RESOLVE_CONFIG = {
browser: true,
dedupe: ['svelte']
};
export default () =>
/** @type {import('vite').UserConfig} */
({
root: 'src/',
base: `/${s_PACKAGE_ID}/`,
publicDir: false,
cacheDir: '../.vite-cache',
resolve: { conditions: ['import', 'browser'] },
esbuild: {
target: ['es2022']
},
css: {
postcss: postcssConfig({ compress: s_COMPRESS, sourceMap: s_SOURCEMAPS })
},
server: {
port: 30001,
open: '/game',
proxy: {
[`^(/${s_PACKAGE_ID}/(assets|lang|packs|style.css))`]: 'http://localhost:30000',
[`^(?!/${s_PACKAGE_ID}/)`]: 'http://localhost:30000',
'/socket.io': { target: 'ws://localhost:30000', ws: true }
}
},
build: {
outDir: __dirname,
emptyOutDir: false,
sourcemap: s_SOURCEMAPS,
brotliSize: true,
minify: s_COMPRESS ? 'terser' : false,
target: ['es2022'],
terserOptions: s_COMPRESS ? { ...terserConfig(), ecma: 2022 } : void 0,
lib: {
entry: 'main.js',
formats: ['es'],
fileName: 'fates-descent'
}
},
optimizeDeps: {
esbuildOptions: {
target: 'es2022'
}
},
plugins: [
svelte({
compilerOptions: {
cssHash: ({ hash, css }) => `svelte-${s_SVELTE_HASH_ID}-${hash(css)}`
},
preprocess: preprocess()
}),
resolve(s_RESOLVE_CONFIG)
]
});