-
Notifications
You must be signed in to change notification settings - Fork 44
/
vite.config.js
68 lines (66 loc) · 2.23 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue2'
import EnvironmentPlugin from 'vite-plugin-environment'
import { NodeModulesPolyfillPlugin } from '@esbuild-plugins/node-modules-polyfill'
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path')
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require('fs')
const packageJson = fs.readFileSync('./package.json')
const appName = JSON.parse(packageJson).appName
const appVersion = JSON.parse(packageJson).version
const sbcName = JSON.parse(packageJson).sbcName
const sbcVersion = JSON.parse(packageJson).dependencies['sbc-common-components']
const aboutApp = (appName && appVersion) ? `${appName} v${appVersion}` : 'Unknown APP'
const aboutSbc = (sbcName && sbcVersion) ? `${sbcName} v${sbcVersion}` : 'Unknown SBC'
// https://vitejs.dev/config/
export default defineConfig(() => {
return {
define: {
'import.meta.env.ABOUT_APP': `"${aboutApp}"`,
'import.meta.env.ABOUT_SBC': `"${aboutSbc}"`
},
envPrefix: 'VUE_APP_', // Need to remove this after fixing vaults. Use import.meta.env with VUE_APP.
plugins: [
vue(),
EnvironmentPlugin({
BUILD: 'web' // Fix for Vuelidate, allows process.env with Vite.
})
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src')
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
// Fix inline dependency of a dependency, which is the case in Tiptap-Vuetify
mainFields: ['module']
},
server: {
host: true,
port: 8080
},
test: {
// simulate DOM with jsdom
environment: 'jsdom',
// enable jest-like global test APIs
globals: true,
setupFiles: ['./tests/setup.ts'],
// enable threads to speed up test running
threads: true,
// hide Vue Devtools message
onConsoleLog: function (log) {
if (log.includes('Download the Vue Devtools extension')) {
return false
}
}
},
optimizeDeps: {
esbuildOptions: {
// Fix Module has been externalized for browser compatibility warning.
plugins: [
NodeModulesPolyfillPlugin()
]
}
}
}
})