-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
/
Copy pathvite-config.js
71 lines (63 loc) · 1.79 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 { readFileSync } from 'node:fs'
import { join } from 'node:path'
import { quasarPath } from './quasar-path.js'
const { version } = JSON.parse(
readFileSync(join(quasarPath, 'package.json'), 'utf-8')
)
export function getViteConfig (runMode, viteMode, externalViteCfg) {
const viteCfg = {
define: {
__QUASAR_VERSION__: `'${ version }'`,
__QUASAR_SSR__: false,
__QUASAR_SSR_SERVER__: false,
__QUASAR_SSR_CLIENT__: false
},
css: {
preprocessorOptions: {
// Use sass-embedded for better stability and performance
sass: {
api: 'modern-compiler',
silenceDeprecations: [ 'import', 'global-builtin' ]
},
scss: {
api: 'modern-compiler',
silenceDeprecations: [ 'import', 'global-builtin' ]
}
}
}
}
// Set this to the default value only if it's not already set.
// @quasar/app-vite configures this by itself when it needs it.
if (!externalViteCfg.define || externalViteCfg.define.__QUASAR_SSR_PWA__ === void 0) {
viteCfg.define.__QUASAR_SSR_PWA__ = false
}
if (runMode === 'ssr-server') {
Object.assign(viteCfg.define, {
__QUASAR_SSR__: true,
__QUASAR_SSR_SERVER__: true
})
}
else {
// Alias "quasar" package to its dev file (which has flags)
// to reduce the number of HTTP requests while in DEV mode
if (viteMode !== 'production') {
viteCfg.resolve = {
alias: [
{ find: /^quasar$/, replacement: 'quasar/dist/quasar.client.js' }
]
}
}
else {
viteCfg.optimizeDeps = {
exclude: [ 'quasar' ]
}
}
if (runMode === 'ssr-client') {
Object.assign(viteCfg.define, {
__QUASAR_SSR__: true,
__QUASAR_SSR_CLIENT__: true
})
}
}
return viteCfg
}