-
Notifications
You must be signed in to change notification settings - Fork 131
Expand file tree
/
Copy pathvite.config.ts
More file actions
94 lines (93 loc) · 2.48 KB
/
vite.config.ts
File metadata and controls
94 lines (93 loc) · 2.48 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import AutoImport from "unplugin-auto-import/vite";
import Components from "unplugin-vue-components/vite";
import { TDesignResolver } from "@tdesign-vue-next/auto-import-resolver";
import { viteSingleFile } from "vite-plugin-singlefile";
import postcsspxtoviewport from "postcss-px-to-viewport";
export default defineConfig({
base: "./",
build: {
assetsInlineLimit: Infinity,
rollupOptions: {
output: {
inlineDynamicImports: true,
},
},
},
plugins: [
vue(),
AutoImport({
dts: "src/types/auto-imports.d.ts",
imports: ["vue", "pinia", "vue-router"],
resolvers: [
TDesignResolver({
library: "vue-next",
}),
TDesignResolver({
library: "chat",
}),
],
}),
Components({
dts: "src/types/components.d.ts",
resolvers: [
TDesignResolver({
library: "vue-next",
}),
TDesignResolver({
library: "chat",
}),
],
}),
viteSingleFile(),
],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
css: {
preprocessorOptions: {
scss: {
api: "modern-compiler",
},
},
postcss: {
plugins: [
postcsspxtoviewport({
// 要转化的单位
unitToConvert: "px",
// UI设计稿的大小
viewportWidth: 1600,
// 转换后的精度
unitPrecision: 4,
// 转换后的单位
viewportUnit: "rem",
// 字体转换后的单位
fontViewportUnit: "rem",
// 能转换的属性,*表示所有属性,!border表示border不转
propList: ["*"],
// 指定不转换为视窗单位的类名,
selectorBlackList: ["ignore"],
// 最小转换的值,小于等于1不转
minPixelValue: 1,
// 是否在媒体查询的css代码中也进行转换,默认false
mediaQuery: true,
// 是否转换后直接更换属性值
replace: true,
// 忽略某些文件夹下的文件或特定文件,例如 'node_modules' 下的文件
exclude: [],
// 包含那些文件或者特定文件
include: [],
// 是否处理横屏情况
landscape: false,
}),
],
},
},
server: {
port: 50188,
},
});