forked from quasarframework/quasar
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-config.js
More file actions
55 lines (47 loc) · 1.39 KB
/
get-config.js
File metadata and controls
55 lines (47 loc) · 1.39 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
import { version } from 'quasar/package.json'
import { normalizePath } from 'vite'
export default ({ runMode, sassVariables }, externalViteCfg) => {
const viteCfg = {
define: {
__QUASAR_VERSION__: `'${ version }'`,
__QUASAR_SSR__: false,
__QUASAR_SSR_SERVER__: false,
__QUASAR_SSR_CLIENT__: false
}
}
// 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 {
viteCfg.optimizeDeps = {
exclude: [ 'quasar' ]
}
if (runMode === 'ssr-client') {
Object.assign(viteCfg.define, {
__QUASAR_SSR__: true,
__QUASAR_SSR_CLIENT__: true
})
}
}
if (sassVariables) {
const sassImportCode = [ `@import 'quasar/src/css/variables.sass'`, '' ]
if (typeof sassVariables === 'string') {
sassImportCode.unshift(`@import '${ normalizePath(sassVariables) }'`)
}
viteCfg.css = {
preprocessorOptions: {
sass: { additionalData: sassImportCode.join('\n') },
scss: { additionalData: sassImportCode.join(';\n') }
}
}
}
return viteCfg
}