forked from bcgov/business-create-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.js
59 lines (56 loc) · 1.91 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
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue2'
import EnvironmentPlugin from 'vite-plugin-environment'
import ViteRequireContext from '@originjs/vite-plugin-require-context'
// eslint-disable-next-line @typescript-eslint/no-var-requires
const path = require('path')
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.
}),
ViteRequireContext() // Support require.context in vite.
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src')
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
},
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
}
}
}
}
})