-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
138 lines (125 loc) · 3.39 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
128
129
130
131
132
133
134
135
136
137
138
// @ts-ignore
import paths from './config/paths.js'
import vue from '@vitejs/plugin-vue'
import WindiCSS from 'vite-plugin-windicss'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import Icons from 'unplugin-icons/vite'
import IconsResolver from 'unplugin-icons/resolver'
// import ElementPlus from 'unplugin-element-plus/vite'
// import VueI18n from '@intlify/vite-plugin-vue-i18n' // TODO add i18n
const esbuild = {} as Record<string, any>
if ( process.env.NODE_ENV === 'production' ) {
esbuild.drop = [ 'console' ]
}
const chunksMap = {
core : [ 'vue', 'vue-router', 'pinia' ],
utils : [ 'lodash', 'date-fns', 'ky' ],
storage: [ 'localforage' ],
}
/**
* https://vitejs.dev/config/
* @type {import('vite').UserConfig}
*/
export default {
css : {
preprocessorOptions: {
scss: {
charset : false,
additionalData: `@use "@assets/styles/element/index.scss" as *;`,
},
},
},
server : {
port : Number( process.env.PORT ) || 8888,
open : false,
proxy: {
'/api': {
target : 'http://localhost:5555/.netlify/functions',
changeOrigin: true,
rewrite : path => path.replace( /^\/api/, '' ),
},
},
},
preview : {
port: 8080
},
resolve : {
alias: paths.makeAliasForVite()
},
plugins : [
vue(),
// VueI18n( {
// fullInstall : true,
// runtimeOnly : false,
// compositionOnly: true,
// // include: `${ paths.ROOT }/src/core/i18n/locales/**`,
// } ),
// ElementPlus( {
// useSource: true,
// } ),
AutoImport( {
include : [
/\.[tj]sx?$/, // .ts, .tsx, .js, .jsx
/\.vue$/, /\.vue\?vue/, // .vue
],
imports : [
'vue',
'vue-i18n',
'@vueuse/head',
'@vueuse/core',
{
'@core/config': [
'config',
]
},
{
'@core/utils': [
'utils',
]
},
],
resolvers: [
ElementPlusResolver( { importStyle: 'sass' } ),
],
dts : 'src/auto-imports.d.ts',
} ),
Components( {
dirs : [ 'src/ui/components', 'src/ui/views' ],
extensions: [ 'vue' ],
deep : true,
include : [ /\.vue$/, /\.vue\?vue/ ],
exclude : [ /[\\/]node_modules[\\/]/, /[\\/]\.git[\\/]/, /[\\/]\.nuxt[\\/]/, /[\\/]\.view.vue[\\/]/ ],
resolvers : [
ElementPlusResolver( { importStyle: 'sass' } ),
IconsResolver( { prefix: 'icon' } ),
],
dts : 'src/components.d.ts',
} ),
WindiCSS(),
Icons( { compiler: 'vue3' } ),
],
esbuild : esbuild,
build : {
sourcemap : false,
rollupOptions: {
output: {
assetFileNames: ( chunk ) => {
return 'assets/[hash][extname]'
},
chunkFileNames: ( chunk ) => {
if ( chunk.name.includes( '.view' ) ) {
return '[name].[hash].js'
}
return '[hash].js'
},
manualChunks : chunksMap,
},
},
},
optimizeDeps: {
entries: [ './src/main.ts' ],
include: [ 'lodash' ]
}
}