-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfeatures.ts
147 lines (128 loc) · 3.98 KB
/
features.ts
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
import { defu } from 'defu'
import OpenProps from 'open-props'
import { log } from './utils/consola'
export function setFeatures() {
// list of optional extra features
const extras = [] as string[]
// list of Nuxt-related settings
const nuxt = [] as string[]
// object for optional config that will be merged with global Nuxt config
// declared in nuxt.config.ts
let nuxtConfig = {
modules: [] as string[],
}
// 1. default modules (mandatory)
nuxtConfig.modules.push(
'nuxt-time',
'nuxt-security',
'@nuxt/eslint',
'@nuxt/image',
'@pinia/nuxt',
'@vueuse/nuxt',
)
// 2. optional modules & features
// ui
const uiPreset = process.env.NUXT_PUBLIC_IGNIS_PRESET_UI
if (uiPreset === 'nuxt-ui' || (!uiPreset && process.env.NUXT_PUBLIC_IGNIS_UI === 'true')) {
nuxtConfig.modules.push('@nuxt/ui')
} else {
// remove @nuxt/ui-specific components from resolution if module is not used
nuxtConfig = defu({
vue: {
compilerOptions: {
isCustomElement: (tag: string) => tag === 'Icon',
},
},
}, nuxtConfig)
// evaluate separate Tailwind CSS module
if (uiPreset === 'tailwind' || (!uiPreset && process.env.NUXT_PUBLIC_IGNIS_TAILWIND === 'true')) {
nuxtConfig.modules.push('@nuxtjs/tailwindcss')
}
}
// database
const dbPreset = process.env.NUXT_PUBLIC_IGNIS_PRESET_DB
if (dbPreset === 'neon' || (!dbPreset && process.env.NUXT_PUBLIC_IGNIS_NEON === 'true')) {
// module definition
nuxtConfig.modules.push('nuxt-neon')
} else if (dbPreset === 'supabase' || (!dbPreset && process.env.NUXT_PUBLIC_IGNIS_SUPABASE === 'true')) {
// module definition
nuxtConfig.modules.push('@nuxtjs/supabase')
// module-specific config key
nuxtConfig = defu({
supabase: {
redirect: false, // https://github.com/supabase/supabase/issues/16551#issuecomment-1685300935
},
}, nuxtConfig)
}
// i18n
if (process.env.NUXT_PUBLIC_IGNIS_I18N_ENABLED === 'true') {
// module definition
nuxtConfig.modules.push('@nuxtjs/i18n')
// module-specific config key
nuxtConfig = defu({
i18n: {
vueI18n: process.env.NUXT_PUBLIC_IGNIS_I18N_CONFIG || './i18n.config.ts',
},
}, nuxtConfig)
}
// formkit
if (process.env.NUXT_PUBLIC_IGNIS_FORMKIT_ENABLED === 'true') {
// module definition
nuxtConfig.modules.push('@formkit/nuxt')
// module-specific config key
nuxtConfig = defu({
formkit: {
autoImport: true,
configFile: process.env.NUXT_PUBLIC_IGNIS_FORMKIT_CONFIG || './formkit.config.ts',
},
}, nuxtConfig)
}
// content
if (process.env.NUXT_PUBLIC_IGNIS_CONTENT === 'true') {
nuxtConfig.modules.push('@nuxt/content')
}
// Open Props CSS
if (process.env.NUXT_PUBLIC_IGNIS_OPENPROPS === 'true') {
extras.push('Open Props CSS')
nuxtConfig = defu({
// import Open Prpops stylesheet
css: ['~/assets/css/open-props.css'],
// CSS processor for Open Props
postcss: {
plugins: {
'postcss-jit-props': OpenProps,
},
},
}, nuxtConfig)
}
// elrh-pslo
if (process.env.NUXT_PUBLIC_IGNIS_PSLO_ENABLED === 'true') {
extras.push('elrh-pslo')
}
// 3. Nuxt-related settings
if (process.env.NUXT_PUBLIC_IGNIS_SSR === 'false') {
nuxtConfig = defu({
ssr: false,
}, nuxtConfig)
nuxt.push('ssr=false')
}
if (process.env.NUXT_PUBLIC_IGNIS_PAGES === 'false') {
nuxtConfig = defu({
pages: false,
}, nuxtConfig)
nuxt.push('pages=false')
}
nuxt.push(`log-level=${process.env.NUXT_PUBLIC_LOG_LEVEL || 'info[default]'}`)
// 4. verify results
// TODO why this run twice?
let overview = 'Nuxt Ignis will start using following settings:\n'
overview += 'Modules: ' + nuxtConfig.modules.join(', ') + '\n'
if (extras.length > 0) {
overview += 'Extras: ' + extras.join(', ') + '\n'
}
if (nuxt.length > 0) {
overview += 'Nuxt: ' + nuxt.join(', ') + '\n'
}
log.info(overview)
return nuxtConfig
}