forked from auroral-ui/hexo-theme-aurora
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
81 lines (76 loc) · 2.34 KB
/
vite.config.js
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
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 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}/[name]-[hash][extname]`;
},
chunkFileNames: 'static/js/[name]-[hash].js',
entryFileNames: 'static/js/[name]-[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(),
],
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/, ''),
}
}
}
})
})