@@ -9,7 +9,7 @@ import Components from 'unplugin-vue-components/vite'
9
9
import { defineConfig } from 'vite'
10
10
import vueSetupExtend from 'vite-plugin-vue-setup-extend'
11
11
12
- const isProduction = process . env . NODE_ENV === 'production'
12
+ const isPreview = process . env . NODE_ENV === 'production'
13
13
14
14
// https://vitejs.dev/config/
15
15
export default defineConfig ( {
@@ -21,25 +21,27 @@ export default defineConfig({
21
21
plugins : [
22
22
AutoImportTypes ( ) ,
23
23
PiniaAutoRefs ( ) ,
24
- AutoImport ( {
25
- dts : 'src/auto-imports.d.ts' , // 可以自定义文件生成的位置,默认是根目录下
26
- imports : [
27
- 'vue' ,
28
- 'vue-router' ,
29
- 'pinia' ,
30
- {
31
- '@/helper/pinia-auto-refs' : [ 'useStore' ] ,
24
+ // 解决 preview 时 auto-imports 文件被修改的问题
25
+ ! isPreview &&
26
+ AutoImport ( {
27
+ dts : 'src/auto-imports.d.ts' , // 可以自定义文件生成的位置,默认是根目录下
28
+ imports : [
29
+ 'vue' ,
30
+ 'vue-router' ,
31
+ 'pinia' ,
32
+ {
33
+ '@/helper/pinia-auto-refs' : [ 'useStore' ] ,
34
+ } ,
35
+ ] ,
36
+ eslintrc : {
37
+ enabled : true , // Default `false`
38
+ filepath : './.eslintrc-auto-import.json' , // Default `./.eslintrc-auto-import.json`
39
+ globalsPropValue : 'readonly' , // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
32
40
} ,
33
- ] ,
34
- eslintrc : {
35
- enabled : true , // Default `false`
36
- filepath : './.eslintrc-auto-import.json' , // Default `./.eslintrc-auto-import.json`
37
- globalsPropValue : 'readonly' , // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
38
- } ,
39
- resolvers : [ ElementPlusResolver ( ) ] ,
40
- } ) ,
41
+ resolvers : [ ElementPlusResolver ( ) ] ,
42
+ } ) ,
41
43
// 解决 preview 时 components 文件被修改的问题
42
- ! isProduction &&
44
+ ! isPreview &&
43
45
Components ( {
44
46
// 指定组件位置,默认是src/components
45
47
dirs : [ 'src/components' ] ,
0 commit comments