-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.js
52 lines (47 loc) · 1.24 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
46
47
48
49
50
51
52
import { fileURLToPath, URL } from 'node:url'
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import { viteStaticCopy } from 'vite-plugin-static-copy'
import { viteExternalsPlugin } from 'vite-plugin-externals'
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const { VITE_CESIUM_LIBS_PATH } = env
const copyCesium = items =>
viteStaticCopy({
targets: [
...items.map(item => ({
src: `node_modules/cesium/Build/Cesium/${item}/*`,
dest: `${VITE_CESIUM_LIBS_PATH}/${item}/`
})),
{
src: 'node_modules/cesium/Build/Cesium/Cesium.js',
dest: `${VITE_CESIUM_LIBS_PATH}/`
}
]
})
return {
plugins: [
vue(),
copyCesium(['Assets', 'ThirdParty', 'Widgets', 'Workers']),
viteExternalsPlugin(
{ cesium: 'Cesium' },
{
disableInServe: true
}
),
{
transformIndexHtml: () => [
{
tag: 'script',
attrs: { src: `${VITE_CESIUM_LIBS_PATH}/Cesium.js` }
}
]
}
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
}
}
}
})