-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
35 lines (33 loc) · 924 Bytes
/
Copy pathvite.config.ts
File metadata and controls
35 lines (33 loc) · 924 Bytes
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
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';
import legacy from '@vitejs/plugin-legacy';
import babel from '@rollup/plugin-babel';
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
// 这个是保证 vite dev 开发环境正常的关键
babel({
babelHelpers: 'bundled',
presets: [
['@babel/preset-env', { targets: '> 0.5%, last 2 versions, not dead' }]
],
plugins: [
'@babel/plugin-proposal-optional-chaining',
'@babel/plugin-proposal-nullish-coalescing-operator'
]
}),
// 这一句是 build 环境正常的关键
legacy({
targets: ['defaults', 'ios>=12', 'ChromeAndroid >= 66'],
additionalLegacyPolyfills: ['core-js/stable'], // 确保引入 `core-js`
modernPolyfills: true
})
],
server: {
host: '0.0.0.0'
},
define: {
_global: {}
}
});