generated from bcgov/bcrs-template-ui
-
Notifications
You must be signed in to change notification settings - Fork 52
/
vite.config.js
66 lines (59 loc) · 2.04 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
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue2'
import EnvironmentPlugin from 'vite-plugin-environment'
// 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']
},
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,
// optionally disable threads to work around canvas module warnings
// but this causes more tests to fail
// ref: https://github.com/vitest-dev/vitest/issues/740
// threads: false,
// hide Vue Devtools message
onConsoleLog: function (log) {
if (log.includes('Download the Vue Devtools extension')) {
return false
}
}
}
}
})