-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
70 lines (65 loc) · 1.72 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
import { fileURLToPath, URL } from 'node:url'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
// import VueDevTools from 'vite-plugin-vue-devtools'
import autoprefixer from "autoprefixer"
import VueI18nPlugin from '@intlify/unplugin-vue-i18n/vite'
export default ({ mode }: { mode: string }) => {
const env = loadEnv(mode, process.cwd())
const SocketIoProxyPath = `^${env.VITE_MIDDLELAYER_API_SOCKET_PATH}`
const ApiIiifProxyPath = [
'^',
String(env.VITE_MIDDLELAYER_API_PATH).replace(/\/+$/, ''),
'/proxy/',
].join('')
// https://vitejs.dev/config/
return defineConfig({
plugins: [
vue(),
vueJsx(),
// VueDevTools(),
VueI18nPlugin({
compositionOnly: false,
strictMessage: false,
escapeHtml: false,
})
],
css: {
postcss: {
plugins: [autoprefixer()],
}
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
},
server: {
proxy: {
[SocketIoProxyPath]: {
target: env.VITE_MIDDLELAYER_API,
ws: true,
changeOrigin: true,
},
// this is from IIIF stored in the datagase, thsy usually contain /api/proxy
[ApiIiifProxyPath]: {
target: env.VITE_MIDDLELAYER_API,
ws: false,
changeOrigin: true,
}
}
},
build: {
rollupOptions: {
output: {
manualChunks: (id) => {
if (id.includes('openseadragon')) return 'openseadragon'
if (id.includes('d3')) return 'd3'
if (id.includes('protobuf')) return 'protobuf'
}
}
}
}
})
}