-
Notifications
You must be signed in to change notification settings - Fork 0
/
vitest.config.ts
78 lines (72 loc) · 1.95 KB
/
vitest.config.ts
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
72
73
74
75
76
77
78
/// <reference types="vitest" />
/// <reference types="vite/client" />
import checker from 'vite-plugin-checker'
import vue from '@vitejs/plugin-vue'
import { defineConfig, loadEnv } from 'vite'
import { visualizer } from 'rollup-plugin-visualizer'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import * as fs from 'fs'
import * as path from 'path'
import { configDefaults } from 'vitest/config'
const appDirectory = fs.realpathSync(process.cwd())
const resolveApp = (relative: string) => path.resolve(appDirectory, relative)
const root = path.resolve(__dirname, resolveApp('src'))
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), '')
const isAnalyze = env.VITE_APP_ENVIRONMENT === 'analyze'
return {
server: {
port: Number(env.VITE_PORT),
},
publicDir: 'static',
plugins: [
vue(),
createSvgIconsPlugin({
iconDirs: [path.resolve(process.cwd(), 'src/assets/icons')],
symbolId: '[name]',
}),
checker({
overlay: {
initialIsOpen: false,
},
typescript: true,
eslint: {
lintCommand:
'eslint "{src,config}/**/*.{vue,js,ts}" --cache --max-warnings=0',
},
}),
...(isAnalyze
? [
visualizer({
open: true,
}),
]
: []),
],
css: {
preprocessorOptions: {
scss: {
additionalData: `
@import "@/styles/_functions.scss";
@import "@/styles/_mixins.scss";
`,
},
},
},
resolve: {
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue'],
dedupe: ['vue'],
alias: {
'@': `${root}/`,
'@config': `${root}/config.ts`,
'@static': `${root}/../static`,
},
},
test: {
globals: true,
environment: 'happy-dom',
exclude: [...configDefaults.exclude],
},
}
})