-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathvite.config.ts
127 lines (107 loc) · 4.03 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
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
import { fileURLToPath } from 'node:url';
// Path
import path from 'path';
// Tailwind
import tailwindcss from '@tailwindcss/vite';
// Vite
import { defineConfig } from 'vite';
// Vite Plugins
import vue from '@vitejs/plugin-vue';
/**
* @description Vite plugin to automatically import files from a directory.
* @see https://github.com/antfu/unplugin-auto-import
*/
import AutoImport from 'unplugin-auto-import/vite';
/**
* @description Vite plugin to minify svg files
* @see https://github.com/vbenjs/vite-plugin-svg-icons
*/
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons';
/**
* @description Vite plugin to automatically import components from a directory.
* @see https://github.com/unplugin/unplugin-vue-components
*
* @note We should know, if we can't use the dynamic component registration with the Vite plugin. So we need to register the components manually. Please check out this issue: https://github.com/unplugin/unplugin-vue-components/issues/643
*/
import Components from 'unplugin-vue-components/vite';
/**
* @description Vite plugin to minify images using imagemin.
* @see https://github.com/unplugin/unplugin-imagemin
*/
import imagemin from 'unplugin-imagemin/vite';
/**
* @description Vite plugin to remove console.log and other console.* calls from your code.
* @see https://github.com/xiaoxian521/vite-plugin-remove-console
*/
import removeConsole from 'vite-plugin-remove-console';
/**
* @description Vite plugin to compress the build output using vite-plugin-compression.
* @see https://github.com/vbenjs/vite-plugin-compression
*/
import viteCompression from 'vite-plugin-compression';
export default defineConfig({
plugins: [
AutoImport({
dts: 'src/auto-imports.d.ts',
dirs: ['src/app/composables', 'src/app/constants', 'src/app/helpers'],
eslintrc: {
enabled: true, // <-- this
},
imports: ['vue', 'vue-router'],
vueTemplate: true,
}),
createSvgIconsPlugin({
// Specify the icon folder to be cached
iconDirs: [path.resolve(process.cwd(), 'src/app/assets/icons')],
// Specify symbolId format
symbolId: 'icon-[dir]-[name]',
}),
Components({
directoryAsNamespace: true,
// relative paths to the directory to search for components.
dirs: ['src/app/components'],
// generate `components.d.ts` global declarations,
// also accepts a path for custom filename
// default: `true` if package typescript is installed
dts: 'src/components.d.ts',
exclude: ['src/app/components/layouts/**'],
extensions: ['vue'],
globalNamespaces: ['global'],
// Glob patterns to match file names to be detected as components.
// When specified, the `dirs` and `extensions` options will be ignored.
// If you want to exclude components being registered, use negative globs with leading `!`.
globs: ['src/app/components/**/*.{vue}'],
include: [/\.vue($|\?)/, /\.md($|\?)/],
resolvers: [
// Element-plus resolver
componentName => {
// ? We need to check, if the component name is includes AppBase prefix. So we can resolve it to the correct path to the component (src/app/components/base)
if (componentName.startsWith('AppBase')) {
return `@components/base/${componentName}.vue`;
}
},
],
// Only provide types of components in library (registered globally)
types: [
{
from: 'vue-router',
names: ['RouterLink', 'RouterView'],
},
],
}),
imagemin(),
removeConsole(),
tailwindcss(),
viteCompression(),
vue(),
],
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url)),
'@assets': fileURLToPath(new URL('./src/app/assets', import.meta.url)),
'@components': fileURLToPath(new URL('./src/app/components', import.meta.url)),
'@composables': fileURLToPath(new URL('./src/app/composables', import.meta.url)),
'@constants': fileURLToPath(new URL('./src/app/constants', import.meta.url)),
},
},
});