-
Notifications
You must be signed in to change notification settings - Fork 64
Expand file tree
/
Copy pathvite.config.ts
More file actions
53 lines (51 loc) · 1.46 KB
/
Copy pathvite.config.ts
File metadata and controls
53 lines (51 loc) · 1.46 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
/// <reference types="vitest" />
import legacy from '@vitejs/plugin-legacy'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import { defineConfig, loadEnv } from 'vite'
import { versionInfoUtil } from '../../common/utils/versionInfoUtil'
import pkg from './package.json'
import { VitePWA } from 'vite-plugin-pwa'
import manifest from './manifest.json'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const appBuild = JSON.parse(env.VITE_APP_VERSION_CONFIG).buildVersion
return {
// A version build (buildVersion vX.Y.Z in VITE_APP_VERSION_CONFIG) is self-contained under /vX.Y.Z/; an empty buildVersion is the root bootstrap.
base: appBuild ? `/${appBuild}/` : '/',
build: {
outDir: appBuild ? `dist/${appBuild}` : 'dist'
},
plugins: [
vue(),
legacy(),
VitePWA({
registerType: "autoUpdate",
selfDestroying: true,
manifest: manifest as any,
devOptions: {
enabled: true
}
})
],
define: {
'import.meta.env.VITE_VERSION_INFO': JSON.stringify(JSON.stringify(versionInfoUtil.getVersionInfo(pkg.version)))
},
resolve: {
dedupe: ['vue', 'pinia', 'vue-router'],
alias: {
'@': path.resolve(__dirname, 'src'),
'@common': path.resolve(__dirname, '../../common'),
'vue': 'vue/dist/vue.esm-bundler.js'
},
},
server: {
port: 8100
},
test: {
globals: true,
environment: 'jsdom'
}
}
})