-
Notifications
You must be signed in to change notification settings - Fork 1
/
vite.config.ts
104 lines (102 loc) · 2.61 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
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
95
96
97
98
99
100
101
102
103
104
import * as path from "path";
import * as fs from "fs";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { getThemeVariables } from "antd/dist/theme";
import vitePluginImp from "vite-plugin-imp";
import sunmaoFsVitePlugin from "./tools/sunmao-fs-vite-plugin";
import linariaVitePlugin from "./tools/linaria-vite-plugin";
import tsconfigPaths from "vite-tsconfig-paths";
import { getProxyConfig, applyK8sYamlPlugin } from "./tools/proxy-k8s";
const globalSassPath = path.resolve(
__dirname,
"./src/_internal/atoms/themes/CloudTower/styles/variables.scss"
);
const globalSass = fs.readFileSync(globalSassPath, "utf-8");
// https://vitejs.dev/config/
export default defineConfig({
build: {
minify: false,
lib: {
entry: path.resolve(__dirname, "src/index.ts"),
name: "Kui",
fileName: (format) => `index.${format}.js`,
formats: ["es"],
},
rollupOptions: {
external: [
"react",
"react-dom",
"@sunmao-ui/core",
"@sunmao-ui/runtime",
"@sunmao-ui/editor-sdk",
"chakra-react-select",
"i18next",
"react-i18next",
],
},
},
server: {
port: 3000,
proxy: {
"/proxy-k8s": getProxyConfig(),
"/api": {
target: "http://192.168.31.181",
ws: true,
},
},
},
plugins: [
tsconfigPaths(),
sunmaoFsVitePlugin({
schemas: [
{
name: "lcm",
path: path.resolve(__dirname, "./src/sunmao/lcm.json"),
},
{
name: "fiddle",
path: path.resolve(__dirname, "./src/sunmao/fiddle.json"),
},
{
name: "yzFiddle",
path: path.resolve(__dirname, "./src/sunmao/yz-fiddle.json"),
},
],
}),
vitePluginImp({
libList: [
{
libName: "antd",
style: (name) => `antd/es/${name}/style`,
},
],
}),
linariaVitePlugin({ preprocessor: "none", extension: ".scss" }),
react(),
applyK8sYamlPlugin(),
],
css: {
preprocessorOptions: {
scss: {
additionalData: `${globalSass}\r\n`,
},
less: {
modifyVars: {
"@ant-prefix": "dovetail-ant",
"@primary-color": "#0080FF",
"@link-color": "#0080FF",
"@text-color": "#06101F",
"@success-color": "#25C764",
"@error-color": "#f0483e",
"@border-radius-base": "3px",
"@screen-xs": "1279px",
"@screen-sm": "1536px",
"@screen-md": "2176px",
"@screen-lg": "2304px",
},
javascriptEnabled: true,
},
},
},
});