-
Notifications
You must be signed in to change notification settings - Fork 81
/
vite.config.ts
110 lines (108 loc) · 2.78 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
import { defineConfig } from "vite";
//@ts-ignore
import path from "path";
import react from "@vitejs/plugin-react";
import vitePluginImp from "vite-plugin-imp";
//@ts-ignore
const resolve = (url) => path.resolve(__dirname, url);
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
'@components': resolve('./src/components'),
'@server': resolve('./src/server'),
'@core': resolve('./src/pages/editor/core'),
'@options': resolve('./src/pages/editor/components/options/components'),
'@plugins': resolve('./src/pages/editor/plugins'),
'@pages': resolve('./src/pages'),
'@language': resolve('./src/language'),
'@hooks': resolve('./src/hooks'),
'@theme': resolve('./src/theme'),
'@layout': resolve('./src/layout'),
'@stores': resolve('./src/stores'),
'@utils': resolve('./src/utils'),
'@config': resolve('./src/config'),
'@less': resolve('./src/less'),
'@images': resolve('./src/assets/images'),
},
extensions: [".mjs", ".js", ".ts", ".jsx", ".tsx", ".json"], // 省略扩展名
},
plugins: [
react({
babel: {
plugins: [
["@babel/plugin-proposal-decorators", { legacy: true }],
["@babel/plugin-proposal-class-properties", { loose: true }],
],
},
}),
vitePluginImp({
libList: [
{
libName: "@icon-park/react",
libDirectory: "es/icons",
camel2DashComponentName: false,
},
{
libName: "lodash",
libDirectory: "",
camel2DashComponentName: false,
},
// {
// libName: '@douyinfe/semi-ui',
// },
],
}),
],
css: {
modules: {
generateScopedName: "[name]__[local]__[hash:5]",
},
preprocessorOptions: {
less: {
// 支持内联 javascript
javascriptEnabled: true,
},
},
},
// 入口
build: {
rollupOptions: {
output: {
chunkFileNames: "editorAssets/js/[name]-[hash].js",
entryFileNames: "editorAssets/js/[name]-[hash].js",
assetFileNames: "editorAssets/[ext]/[name]-[hash].[ext]",
},
input: {
main: resolve("index.html"),
},
},
minify: "terser",
terserOptions: {
compress: {
//生产环境时移除console
drop_console: true,
drop_debugger: true,
},
},
},
base: "/", // 公共基础路径
server: {
host: "0.0.0.0",
port: 3004,
proxy: {
'/cgi-bin': {
target: 'https://image.h5ds.com',
changeOrigin: true,
},
'/api': {
target: 'https://image.h5ds.com',
changeOrigin: true,
},
'/fonts': {
target: 'https://cdn.h5ds.com/assets',
changeOrigin: true,
},
},
},
});