-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
72 lines (69 loc) · 1.88 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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import viteCompression from 'vite-plugin-compression'
import path from 'path'
import htmlPlugin from 'vite-plugin-html-config'
// https://vitejs.dev/config/
export default defineConfig({
server: {
port: 3000,
proxy: {
'/api': {
// target: 'https://ai.nieyunliang.com',
target: 'http://localhost:8000',
rewrite: path => path.replace('/api', '')
}
}
},
resolve: {
alias: [{ find: '@', replacement: path.resolve(__dirname, 'src') }]
},
build: {
rollupOptions: {
output: {
manualChunks(id) {
if (id.includes('node_modules')) {
const modules = id.toString().split('node_modules/')[1].split('/')
if (modules[1].includes('ant')) {
return 'ant'
} else if (modules[1].includes('react')) {
return 'react'
} else if (
modules[1].includes('highlight') ||
modules[1].includes('marked')
) {
return 'code-highlight'
} else if (modules[1].includes('lodash')) {
return 'lodash'
} else {
console.log(modules[1])
return 'vendor'
}
}
return 'index'
}
}
}
},
plugins: [
react(),
viteCompression(),
process.env.NODE_ENV === 'production'
? htmlPlugin({
scripts: [
{
content: `
var _hmt = _hmt || [];
(function () {
var hm = document.createElement("script");
hm.src = "https://hm.baidu.com/hm.js?e136f7bf7934ff74190e817043cb4727";
var s = document.getElementsByTagName("script")[0];
s.parentNode.insertBefore(hm, s);
})();
`
}
]
})
: null
]
})