-
Notifications
You must be signed in to change notification settings - Fork 120
/
vite.config.js
45 lines (43 loc) · 1.27 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
import { fileURLToPath, URL } from 'node:url'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import { quasar, transformAssetUrls } from '@quasar/vite-plugin'
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
import { resolve, dirname } from 'node:path'
import { existsSync } from 'fs'
const dotPathFixPlugin = () => ({
name: "dot-path-fix-plugin",
configureServer: (server) => {
server.middlewares.use((req, _, next) => {
const reqPath = req.url.split("?", 2)[0]
if (
!req.url.startsWith("/@") && // virtual files provided by vite plugins
!req.url.startsWith("/api/") && // api proxy, configured below
!existsSync(`./public${reqPath}`) && // files served directly from public folder
!existsSync(`.${reqPath}`) // actual files
) {
req.url = "/"
}
next()
})
},
})
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue({
template: { transformAssetUrls }
}),
quasar(),
VueI18nPlugin({
strictMessage: false,
include: resolve(dirname(fileURLToPath(import.meta.url)), './src/i18n/locales/**'),
}),
dotPathFixPlugin()
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
})