-
Notifications
You must be signed in to change notification settings - Fork 212
Expand file tree
/
Copy pathvite.config.js
More file actions
88 lines (84 loc) Β· 2.38 KB
/
Copy pathvite.config.js
File metadata and controls
88 lines (84 loc) Β· 2.38 KB
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
import { defineConfig, loadEnv } from 'vite'
import vue from '@vitejs/plugin-vue'
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import { createHtmlPlugin } from 'vite-plugin-html-transformer'
import Pages from 'vite-plugin-pages'
import path from 'path'
// https://vitejs.dev/config/
export default ({ mode }) => {
process.env = { ...process.env, ...loadEnv(mode, process.cwd()) }
const filenamePath =
process.env.VITE_MODE === 'production'
? '../layout/index.ejs'
: 'index.html'
const templatePath =
process.env.VITE_MODE === 'production'
? 'templates/index_prod.html'
: 'templates/index.html'
return defineConfig({
build: {
outDir: 'source',
assetsDir: 'static',
rollupOptions: {
output: {
assetFileNames: assetInfo => {
let extType = assetInfo.name.split('.').at(1)
if (/png|jpe?g|svg|gif|tiff|bmp|ico/i.test(extType)) {
extType = 'img'
}
return `static/${extType}/[hash][extname]`
},
chunkFileNames: 'static/js/[hash].js',
entryFileNames: 'static/js/[hash].js'
},
plugins: []
}
},
plugins: [
createSvgIconsPlugin({
// Specify the icon folder to be cached
iconDirs: [path.resolve(process.cwd(), 'src/icons')],
// Specify symbolId format
symbolId: 'icon-[dir]-[name]',
/**
* custom insert position
* @default: body-last
*/
// inject: 'body-last' | 'body-first',
/**
* custom dom id
* @default: __svg__icons__dom__
*/
customDomId: '__svg__icons__dom__'
}),
createHtmlPlugin({
minify: true,
entry: '/src/main.ts',
filename: filenamePath,
template: templatePath
}),
vue(),
Pages({})
],
resolve: {
alias: {
'@': path.resolve(__dirname, './src')
},
extensions: ['.mjs', '.js', '.ts', '.jsx', '.tsx', '.json', '.vue']
},
server: {
proxy: {
'/api': {
target: 'http://localhost:4000/api',
changeOrigin: true,
rewrite: path => path.replace(/^\/api/, '')
},
'/assets': {
target: 'http://localhost:4000/assets',
changeOrigin: true,
rewrite: path => path.replace(/^\/assets/, '')
}
}
}
})
}