-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathvite.config.js
More file actions
71 lines (64 loc) · 1.89 KB
/
vite.config.js
File metadata and controls
71 lines (64 loc) · 1.89 KB
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
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 svgLoader from 'vite-svg-loader';
import fs from 'node:fs';
import { viteStaticCopy } from 'vite-plugin-static-copy';
const cesiumSource = 'node_modules/cesium/Build/Cesium';
const cesiumBaseUrl = 'public/cesium';
// process.env.VITE_APP_VERSION = process.env.npm_package_version;
// https://vite.dev/config/
// The function argument automatically provides 'mode'
export default defineConfig(({ mode }) => {
// Load env file based on 'mode' in the current working directory.
// Second argument is the directory where env files are located.
const env = loadEnv(mode, process.cwd(), '');
const packageJson = JSON.parse(
fs.readFileSync(new URL('./package.json', import.meta.url), 'utf-8')
);
return {
base: env.VITE_VIEWER_ENDPOINT,
plugins: [
vue(),
vueJsx(),
vueDevTools(),
svgLoader(),
viteStaticCopy({
targets: [
{ src: `${cesiumSource}/ThirdParty`, dest: cesiumBaseUrl },
{ src: `${cesiumSource}/Workers`, dest: cesiumBaseUrl },
{ src: `${cesiumSource}/Assets`, dest: cesiumBaseUrl },
{ src: `${cesiumSource}/Widgets`, dest: cesiumBaseUrl },
],
}),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'osh-js': fileURLToPath(new URL('./lib/osh-js', import.meta.url)),
},
},
build: {
rollupOptions: {
external: ['fsevents', 'node:path'],
},
},
ssr: {
noExternal: ['osh-js', 'cesium', 'leaflet'],
},
optimizeDeps: {
include: ['cesium', 'leaflet', 'osh-js'],
exclude: [],
},
worker: {
format: 'es',
rollupOptions: {},
},
define: {
CESIUM_BASE_URL: JSON.stringify(cesiumBaseUrl),
APP_VERSION: JSON.stringify(packageJson.version),
},
};
});