-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathvite.config.ts
125 lines (123 loc) · 3.22 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
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import * as path from "path";
import * as fs from "fs";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
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";
import monacoEditorPlugin from "vite-plugin-monaco-editor";
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: {
index: path.resolve(__dirname, "src/index.ts"),
widgets: path.resolve(__dirname, "src/widgets.ts"),
},
name: "Kui",
fileName: (format, entryName) => `${entryName}.js`,
formats: ["es", "cjs"],
},
rollupOptions: {
external: [
"react",
"react-dom",
"semver",
"@sunmao-ui/core",
"@sunmao-ui/runtime",
"@sunmao-ui/editor-sdk",
"chakra-react-select",
"monaco-editor",
"monaco-yaml",
"@cloudtower/eagle"
],
},
},
server: {
host: '0.0.0.0',
port: 8080,
proxy: {
"/proxy-k8s": getProxyConfig(),
"/api": {
target: "http://10.255.5.44",
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"),
},
{
name: "kgt",
path: path.resolve(__dirname, "./src/sunmao/kgt.json"),
},
{
name: "deployment",
path: path.resolve(__dirname, "./src/sunmao/deployment.json"),
},
{
name: "validation",
path: path.resolve(__dirname, "./src/sunmao/validation.json"),
},
],
}),
vitePluginImp({
libList: [
{
libName: "antd",
style: (name) => `antd/es/${name}/style`,
},
],
}),
linariaVitePlugin({ preprocessor: "none", extension: ".scss" }),
react(),
applyK8sYamlPlugin(),
monacoEditorPlugin({
languageWorkers: ["json", "editorWorkerService"],
}),
],
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,
},
},
},
});