加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
vite.config.ts 3.61 KB
一键复制 编辑 原始数据 按行查看 历史
zss 提交于 2024-05-09 22:04 . feat: 代理配置
import path from "path";
import vue from "@vitejs/plugin-vue";
import { resolve } from "path";
import { defineConfig, loadEnv, UserConfig, UserConfigExport } from "vite";
import html from "vite-plugin-html";
import tsconfigPaths from "vite-tsconfig-paths";
import { createSvgIconsPlugin } from "vite-plugin-svg-icons";
import { mars3dPlugin } from "vite-plugin-mars3d";
import { createStyleImportPlugin,AndDesignVueResolve,} from "vite-plugin-style-import";
const prefix = `monaco-editor/esm/vs`;
export default (config: UserConfig): UserConfigExport => {
const mode = config.mode as string;
return defineConfig({
base: "./",
optimizeDeps: {
include: [
`${prefix}/language/json/json.worker`,
`${prefix}/language/css/css.worker`,
`${prefix}/language/html/html.worker`,
`${prefix}/language/typescript/ts.worker`,
`${prefix}/editor/editor.worker`,
"@jiaminghi/c-render",
"@jiaminghi/c-render/lib/plugin/util",
"@jiaminghi/charts/lib/util/index",
"@jiaminghi/charts/lib/util",
"@jiaminghi/charts/lib/extend/index",
"@jiaminghi/charts",
"@jiaminghi/color",
"@/../lib/vform/designer.umd.js"
]
},
css:{
preprocessorOptions: {
less: {
javascriptEnabled: true,
additionalData: `@import "${path.resolve(
__dirname,
"src/components/mars-ui/base.less"
)}";`,
},
},
},
plugins: [
vue(),
mars3dPlugin(),
html({
inject: {
injectData: {
apiURL: loadEnv(mode, process.cwd()).VITE_APP_API,
title: ""
}
},
minify: true
}),
tsconfigPaths(),
//#mars3d开始
createSvgIconsPlugin({
iconDirs: [resolve(__dirname, "src/assets/icons/svg")],
symbolId: "icon-[dir]-[name]"
}),
createStyleImportPlugin({
resolves: [AndDesignVueResolve()],
libs: [{
libraryName: "ant-design-vue",
esModule: true,
resolveStyle: (name) => {
if (name === "auto-complete") {
return `ant-design-vue/es/${name}/index`;
}
return `ant-design-vue/es/${name}/style/index`;
}
}]
}),
//#mars3d结束
],
build: {
chunkSizeWarningLimit: 1024,
commonjsOptions: {
include: /node_modules|lib/
},
rollupOptions: {
output: {
manualChunks: {
monacoeditor: ["monaco-editor"],
quill: ["quill"],
lodash: ["lodash"],
lib: ["sortablejs", "vxe-table", "xe-utils"],
vlib: ["vue", "vue-router", "vue-i18n", "element-plus"]
}
}
}
},
//#mars3d开始
define: {
"process.env": {
mode,
BASE_URL: loadEnv(mode, process.cwd()).VITE_BASE_URL,
API_BASE: loadEnv(mode, process.cwd()).VITE_API_URL,
API_LOCAL: loadEnv(mode, process.cwd()).VITE_LOCAL_API
},
buildTime: new Date()
},
//#mars3d结束
resolve: {
alias: {
// 配置别名
"@": resolve(__dirname, "./src"),
"vue-i18n": "vue-i18n/dist/vue-i18n.cjs.js"
}
},
server: {
open: true, // 自动启动浏览器
host: "0.0.0.0", // localhost
port: 8001, // 端口号
https: false,
proxy: {
"/prod-api": {
// target: "http://whkc.natapp1.cc:8080",
target: "http://1.92.105.211",
ws: true,
changeOrigin: true,
// rewrite: (path) => path.replace(/^\/api/, ''),
}
}
}
});
};
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化