-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathvite.config.ts
59 lines (57 loc) · 1.7 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
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import eslintPlugin from 'vite-plugin-eslint'
import { viteMockServe } from 'vite-plugin-mock'
import path from 'path'
import proxy from './config/proxy'
// https://vitejs.dev/config/
export default defineConfig(({ mode }) => ({
plugins: [
react(),
eslintPlugin({
include: ['src/**/*.js', 'src/**/*.ts', 'src/**/*.tsx', 'src/*.js', 'src/*.ts', 'src/*.tsx']
}),
viteMockServe({
// default
localEnabled: mode === 'mock',
mockPath: './config/mock'
})
],
resolve: {
extensions: ['.mjs', '.js', '.jsx', '.ts', '.tsx', '.json', '.sass', '.scss'], // 忽略输入的扩展名
alias: [
{ find: /^~/, replacement: '' },
{ find: '@', replacement: path.resolve(__dirname, 'src') },
{ find: '~', replacement: path.resolve(__dirname, './node_modules') },
{
find: '@components',
replacement: path.resolve(__dirname, 'src/components')
},
{ find: '@config', replacement: path.resolve(__dirname, 'config') },
// {
// find: '@antd/dist/reset.css',
// replacement: path.join(__dirname, 'node_modules/antd/dist/reset.css')
// }
// // { find: 'antd', replacement: path.join(__dirname, 'node_modules/antd/dist/antd.js') },
// // {
// // find: '@ant-design/icons',
// // replacement: path.join(__dirname, 'node_modules/@ant-design/icons/dist/index.umd.js')
// // }
]
},
css: {
preprocessorOptions: {
less: {
// 支持内联 JavaScript
javascriptEnabled: true
}
}
},
server: {
proxy: proxy[mode]
},
build: {
// 打包出map文件
sourcemap: true
}
}))