forked from frzyc/genshin-optimizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.mts
94 lines (86 loc) · 2.37 KB
/
vite.config.mts
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/// <reference types='vitest' />
import react from '@vitejs/plugin-react'
import { resolve } from 'path'
import { defineConfig, normalizePath } from 'vite'
// viteStaticCopy contains some `require`, so we need to have our config as .mts instead of .ts.
// https://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only
import { nxViteTsPaths } from '@nx/vite/plugins/nx-tsconfig-paths.plugin'
import { viteStaticCopy } from 'vite-plugin-static-copy'
export default defineConfig({
base: '',
root: __dirname,
cacheDir: '../../node_modules/.vite/apps/viteapp',
server: {
port: 4200,
host: 'localhost',
fs: {
cachedChecks: false,
},
},
preview: {
port: 4300,
host: 'localhost',
},
plugins: [
react(),
nxViteTsPaths(),
// Nx executor for vite does not support `assets` prop for copying files.
// So we need to do it with this plugin. This works for both `build` and `serve`.
viteStaticCopy({
targets: [
{
src: normalizePath(
resolve('../../libs/common/localization/assets/locales')
),
dest: 'assets',
},
{
src: normalizePath(
resolve('../../libs/sr/localization/assets/locales')
),
dest: 'assets',
},
{
src: normalizePath(
resolve('../../libs/sr/dm-localization/assets/locales')
),
dest: 'assets',
},
{
src: normalizePath(resolve('../../apps/sr-frontend/assets/*')),
dest: 'assets',
},
],
// Force page to reload if we change any of the above files
watch: {
reloadPageOnChange: true,
},
}),
],
define: {
'process.env': process.env,
},
// Uncomment this if you are using workers.
worker: {
// https://vitejs.dev/guide/migration#worker-plugins-is-now-a-function
plugins: () => [nxViteTsPaths()],
},
build: {
outDir: '../../dist/apps/sr-frontend',
reportCompressedSize: true,
commonjsOptions: {
transformMixedEsModules: true,
},
},
test: {
globals: true,
cache: { dir: '../../node_modules/.vitest' },
environment: 'jsdom',
include: ['src/**/*.{test,spec}.{js,mjs,cjs,ts,mts,cts,jsx,tsx}'],
reporters: ['default'],
coverage: {
reportsDirectory: '../../coverage/apps/sr-frontend',
provider: 'v8',
},
},
})