-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.ts
53 lines (50 loc) · 1.43 KB
/
vite.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
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import path from 'path'
import {
BaseElementNode,
DirectiveNode,
SimpleExpressionNode,
} from '@vue/compiler-core'
const TEST_PREFIX = 'data-test'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
vue({
template: {
compilerOptions: {
nodeTransforms: [
(node: any) => {
if (process.env.E2E === '1') return
if (!Array.isArray(node.props)) return
node.props = (node as BaseElementNode).props.filter((p) => {
switch (p.type) {
case 6:
return !p.name.startsWith(TEST_PREFIX)
case 7: {
const dir = p as DirectiveNode
if (!dir.arg) return true
if (dir.arg.type !== 4) return true
return !(
dir.arg as SimpleExpressionNode
).content.startsWith(TEST_PREFIX)
}
default:
return true
}
})
},
],
},
},
}),
],
resolve: {
alias: [{ find: '/@', replacement: path.resolve(__dirname, 'src') }],
},
base: process.env.BASE_PATH || '/',
define: {
'process.env.APP_VERSION': JSON.stringify(process.env.npm_package_version),
__VUE_OPTIONS_API__: false,
},
})