forked from Cap-go/capgo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
209 lines (197 loc) · 5.58 KB
/
vite.config.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
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
/// <reference types="vitest" />
import path from 'node:path'
import Vue from '@vitejs/plugin-vue'
// import veauryVitePlugins from 'veaury/vite/index'
import { defineConfig } from 'vite'
import Pages from 'vite-plugin-pages'
import Layouts from 'vite-plugin-vue-layouts'
import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'
import Components from 'unplugin-vue-components/vite'
import { VitePWA } from 'vite-plugin-pwa'
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
import Inspector from 'vite-plugin-vue-inspector'
import Inspect from 'vite-plugin-inspect'
import EnvironmentPlugin from 'vite-plugin-environment'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import { readdirSync } from 'fs-extra'
import { branch, getRightKey } from './scripts/utils.mjs'
import pack from './package.json'
function getUrl(): string {
if (branch === 'local')
return `http://${getRightKey('base_domain')}`
else
return `https://${getRightKey('base_domain')}`
}
const locales: string[] = []
readdirSync('./locales/')
.forEach((file) => {
if (file.split('.')[0] !== 'README')
locales.push(file.split('.')[0])
})
// const markdownWrapperClasses = 'prose prose-xl m-auto text-left'
const guestPath = ['/login', '/register', '/forgot_password', '/onboarding/confirm_email', '/onboarding/verify_email', '/onboarding/activation', '/onboarding/set_password']
export default defineConfig({
resolve: {
alias: {
'~/': `${path.resolve(__dirname, 'src')}/`,
},
},
plugins: [
Vue({
include: [/\.vue$/, /\.md$/],
}),
// veauryVitePlugins({
// type: 'vue',
// // Configuration of @vitejs/plugin-vue
// vueOptions: {
// include: [/\.vue$/, /\.md$/],
// },
// // Configuration of @vitejs/plugin-react
// // reactOptions: {...},
// // Configuration of @vitejs/plugin-vue-jsx
// // vueJsxOptions: {...}
// }),
Components({
resolvers: [
IconsResolver(),
ElementPlusResolver({
importStyle: 'sass',
}),
],
}),
EnvironmentPlugin({
locales: locales.join(','),
VITE_APP_VERSION: pack.version,
VITE_SUPABASE_ANON_KEY: getRightKey('supa_anon'),
VITE_SUPABASE_URL: getRightKey('supa_url'),
VITE_APP_URL: `${getUrl()}`,
VITE_BRANCH: branch,
package_dependencies: JSON.stringify(pack.dependencies),
domain: getUrl(),
pls_domain: 'web.capgo.app',
logsnag: 'c124f5e9d0ce5bdd14bbb48f815d5583',
crisp: 'e7dbcfa4-91b1-4b74-b563-b9234aeb2eee',
}, { defineOn: 'import.meta.env' }),
// https://github.com/hannoeru/vite-plugin-pages
Pages({
resolver: 'vue',
extensions: ['vue', 'md'],
// onRoutesGenerated(routes) {
// console.log('routes', routes)
// },
extendRoute: (route) => {
if (guestPath.includes(route.path)) {
return {
...route,
meta: { ...route.meta, layout: 'auth' },
}
}
// Augment the route with meta that indicates that the route requires authentication.
return {
...route,
meta: { ...route.meta, middleware: 'auth' },
}
},
}),
// https://github.com/JohnCampionJr/vite-plugin-vue-layouts
Layouts(),
// https://github.com/antfu/unplugin-icons
Icons({
autoInstall: true,
}),
// https://github.com/antfu/vite-plugin-pwa
VitePWA({
registerType: 'autoUpdate',
includeAssets: ['favicon.svg', 'robots.txt', 'safari-pinned-tab.svg'],
manifest: {
name: 'Capgo',
short_name: 'CapGo',
theme_color: '#ffffff',
icons: [
{
src: '/pwa-192x192.png',
sizes: '192x192',
type: 'image/png',
},
{
src: '/pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
},
{
src: '/pwa-512x512.png',
sizes: '512x512',
type: 'image/png',
purpose: 'any maskable',
},
],
},
}),
// https://github.com/intlify/bundle-tools/tree/main/packages/unplugin-vue-i18n
VueI18nPlugin({
runtimeOnly: true,
compositionOnly: true,
fullInstall: true,
include: [path.resolve(__dirname, 'locales/**')],
// availableLocales: [path.resolve(__dirname, 'locales/**')
}),
// https://github.com/antfu/vite-plugin-inspect
// Visit http://localhost:3333/__inspect/ to see the inspector
Inspect(),
// https://github.com/webfansplz/vite-plugin-vue-inspector
Inspector({
toggleButtonVisibility: 'never',
}),
// ViteImagemin({
// gifsicle: {
// optimizationLevel: 7,
// interlaced: false,
// },
// optipng: {
// optimizationLevel: 7,
// },
// mozjpeg: {
// quality: 20,
// },
// pngquant: {
// quality: [0.8, 0.9],
// speed: 4,
// },
// svgo: {
// plugins: [
// {
// name: 'removeViewBox',
// },
// {
// name: 'removeEmptyAttrs',
// active: false,
// },
// ],
// },
// }),
],
server: {
fs: {
strict: true,
},
},
optimizeDeps: {
include: [
'vue',
'vue-router',
'@vueuse/core',
],
exclude: [
'vue-demi',
],
},
// https://github.com/vitest-dev/vitest
test: {
include: ['test/**/*.test.ts'],
environment: 'jsdom',
deps: {
inline: ['@vue', '@vueuse', 'vue-demi'],
},
},
})