-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathvite.config.js
52 lines (50 loc) · 1.52 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
import { defineConfig } from 'vite'
import path from 'path'
import react from '@vitejs/plugin-react'
import reactRefresh from '@vitejs/plugin-react-refresh'
import AutoImport from 'unplugin-auto-import/vite'
import dotenv from 'dotenv'
dotenv.config()
// TODO 报错了,先注释
// import { createStyleImportPlugin, AntdResolve } from "vite-plugin-style-import"
export default defineConfig({
plugins: [
react(),
reactRefresh(), // 热更新
AutoImport({
include: [/\.[tj]sx?$/],
imports: ['react', 'react-router'],
}),
// Antd 的样式使用了 Less 作为开发语言,为了减小 antd 的 css,变全局引入为按需引入
// createStyleImportPlugin({ resolve: [AntdResolve] })
],
css: {
// CSS 预处理器的配置选项
preprocessorOptions: {
less: {
additionalData: `@import "${path.resolve(__dirname, 'src/assests/index.less')}";`, // 全局变量
},
},
},
resolve: {
alias: {
'@': path.resolve(__dirname, 'src'),
},
},
build: {
emptyOutDir: true,
rollupOptions: {
input: {
// 配置所有页面路径,使得所有页面都会被打包
index: path.resolve(__dirname, 'index.html'),
login: path.resolve(__dirname, '/pages/login.html'),
newtab: path.resolve(__dirname, '/pages/newtab.html'),
},
output: {
assetFileNames: 'assets/[name]-[hash].[ext]',
entryFileNames: 'assets/[name]-[hash].js',
chunkFileNames: 'assets/[name]-[hash].js',
},
},
},
})