-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
74 lines (66 loc) · 2.61 KB
/
vite.config.ts
File metadata and controls
74 lines (66 loc) · 2.61 KB
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
import { fileURLToPath } from 'node:url'
import { dirname, resolve } from 'node:path'
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import svgr from 'vite-plugin-svgr'
const rootPath = dirname( fileURLToPath( import.meta.url ) )
// https://vite.dev/config/
export default defineConfig({
publicDir: false,
plugins: [
react(),
svgr({
svgrOptions: {
// we include a plugin to optimize SVGs
plugins: ["@svgr/plugin-svgo", "@svgr/plugin-jsx"],
svgoConfig: {
floatPrecision: 3,
},
},
})
],
resolve: {
alias: {
"&internal-interface": resolve(rootPath, "./src/_internal-interface/"),
"@core:routing": resolve(rootPath, "./src/core/routing/"),
"@core:components": resolve(rootPath, "./src/core/components/"),
"@core:hooks": resolve(rootPath, "./src/core/hooks/"),
"@core:utils": resolve(rootPath, "./src/core/utils/"),
"@core:assets": resolve(rootPath, "./src/core/assets/"),
"@components": resolve(rootPath, "./src/shared/components/"),
"@hooks": resolve(rootPath, "./src/shared/hooks/"),
"@utils": resolve(rootPath, "./src/shared/utils/"),
"@assets": resolve(rootPath, "./src/shared/assets/"),
"@sites": resolve(rootPath, "./src/shared/sites/"),
},
},
css: {
preprocessorOptions: {
scss: {
api: 'modern-compiler' // default used by vite is deprecated
}
}
},
build: {
emptyOutDir: false, // manually handling output dir beacause it contains multiple sites
outDir: './dist/client',
target: 'ES2015',
copyPublicDir: false, // we don't use the public dir so we disable it
rollupOptions: {
output: {
assetFileNames: 'assets/[ext]/[name]-[hash:12][extname]',
chunkFileNames: 'assets/js/chunks/[name]-[hash:12].js',
entryFileNames: ( chunkInfo ) => {
/* this is called for both 'entry-server' and 'entry-client'
and we want the client index to be in assets/js/...
and the server entry to be at root without hash (to find it easier)
*/
if ( chunkInfo.name.match( /entry-server/ ) ) {
return '[name].js'
}
return 'assets/js/[name]-[hash:12].js'
}
}
}
}
})