chore: consume timi packages from nexus instead of local links
This commit is contained in:
+73
-142
@@ -1,153 +1,84 @@
|
||||
import { fileURLToPath, URL } from "node:url";
|
||||
import { defineConfig, loadEnv } from "vite";
|
||||
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 "unplugin-vue-components/resolvers";
|
||||
|
||||
const localTimiWebRoot = fileURLToPath(new URL("../timi-web", import.meta.url));
|
||||
const localTimiWebModule = fileURLToPath(new URL("../timi-web/src/index.ts", import.meta.url));
|
||||
const localTimiWebStyle = fileURLToPath(new URL("../timi-web/dist/timi-web.css", import.meta.url));
|
||||
const localTimiWebEditor = fileURLToPath(new URL("../timi-web/src/editor/index.ts", import.meta.url));
|
||||
const localTimiWebApiRoot = fileURLToPath(new URL("../timi-web-api", import.meta.url));
|
||||
const localTimiWebApiModule = fileURLToPath(new URL("../timi-web-api/dist/index.js", import.meta.url));
|
||||
const localTimiTsModule = fileURLToPath(new URL("../timi-ts/src/index.ts", import.meta.url));
|
||||
const localTimiTDesignMobileRoot = fileURLToPath(new URL("../timi-tdesign-mobile", import.meta.url));
|
||||
const localTimiTDesignMobileModule = fileURLToPath(new URL("../timi-tdesign-mobile/src/index.ts", import.meta.url));
|
||||
const localTimiTDesignMobileStyle = fileURLToPath(new URL("../timi-tdesign-mobile/dist/timi-tdesign-mobile.css", import.meta.url));
|
||||
const projectRoot = fileURLToPath(new URL(".", import.meta.url));
|
||||
|
||||
export default defineConfig(({ mode }) => {
|
||||
const env = loadEnv(mode, process.cwd(), "");
|
||||
const useLocalTimiWeb = env.VITE_USE_LOCAL_TIMI_WEB !== "false";
|
||||
const useLocalTimiTDesignMobile = env.VITE_USE_LOCAL_TIMI_TDESIGN_MOBILE !== "false";
|
||||
return {
|
||||
resolve: {
|
||||
dedupe: ["vue", "pinia", "vue-router"],
|
||||
alias: [
|
||||
{
|
||||
find: "@",
|
||||
replacement: fileURLToPath(new URL("./src", import.meta.url))
|
||||
},
|
||||
...(useLocalTimiWeb
|
||||
? [
|
||||
{
|
||||
find: /^timi-web$/,
|
||||
replacement: localTimiWebModule
|
||||
},
|
||||
{
|
||||
find: /^timi-web\/editor$/,
|
||||
replacement: localTimiWebEditor
|
||||
},
|
||||
{
|
||||
find: /^timi-web\/style\.css$/,
|
||||
replacement: localTimiWebStyle
|
||||
}
|
||||
]
|
||||
: []),
|
||||
{
|
||||
find: /^timi-web-api$/,
|
||||
replacement: localTimiWebApiModule
|
||||
},
|
||||
{
|
||||
find: /^timi-web-api\//,
|
||||
replacement: `${localTimiWebApiRoot}/dist/`
|
||||
},
|
||||
...(useLocalTimiWeb
|
||||
? [
|
||||
{
|
||||
find: /^timi-ts$/,
|
||||
replacement: localTimiTsModule
|
||||
}
|
||||
]
|
||||
: []),
|
||||
...(useLocalTimiTDesignMobile
|
||||
? [
|
||||
{
|
||||
find: /^timi-tdesign-mobile$/,
|
||||
replacement: localTimiTDesignMobileModule
|
||||
},
|
||||
{
|
||||
find: /^timi-tdesign-mobile\/style\.css$/,
|
||||
replacement: localTimiTDesignMobileStyle
|
||||
}
|
||||
]
|
||||
: [])
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
vue(),
|
||||
AutoImport({
|
||||
imports: ["vue", "vue-router", "pinia"],
|
||||
dts: "auto-imports.d.ts",
|
||||
eslintrc: {
|
||||
enabled: true,
|
||||
filepath: "./.eslintrc-auto-import.json",
|
||||
globalsPropValue: true
|
||||
},
|
||||
resolvers: [
|
||||
TDesignResolver({
|
||||
library: "mobile-vue"
|
||||
})
|
||||
]
|
||||
}),
|
||||
Components({
|
||||
dirs: ["src/components", "src/layout"],
|
||||
dts: "components.d.ts",
|
||||
resolvers: [
|
||||
TDesignResolver({
|
||||
library: "mobile-vue"
|
||||
}),
|
||||
(name) => {
|
||||
if (name === "CardContainer") {
|
||||
return {
|
||||
name: "CardContainer",
|
||||
from: "timi-tdesign-mobile"
|
||||
};
|
||||
}
|
||||
if (name === "CenterTips") {
|
||||
return {
|
||||
name: "CenterTips",
|
||||
from: "timi-web"
|
||||
};
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
],
|
||||
css: {
|
||||
preprocessorOptions: {
|
||||
less: {
|
||||
javascriptEnabled: true
|
||||
}
|
||||
export default defineConfig({
|
||||
resolve: {
|
||||
dedupe: ["vue", "pinia", "vue-router"],
|
||||
alias: [
|
||||
{
|
||||
find: "@",
|
||||
replacement: fileURLToPath(new URL("./src", import.meta.url))
|
||||
}
|
||||
},
|
||||
server: {
|
||||
port: 84,
|
||||
allowedHosts: [
|
||||
"gao.imyeyu.com"
|
||||
],
|
||||
/**
|
||||
* 调试产物(截图、CDP 脚本、Chrome 的 user-data-dir)不能被监听:
|
||||
* Chrome 运行时锁着里面的 SQLite,chokidar 一 watch 就 EBUSY 把 dev server 打挂。
|
||||
* 默认的 .git / node_modules 需要显式保留,因为这里的 ignored 会覆盖默认值。
|
||||
*/
|
||||
watch: {
|
||||
ignored: [
|
||||
"**/.git/**",
|
||||
"**/node_modules/**",
|
||||
"**/.debug-*",
|
||||
"**/.debug-*/**"
|
||||
]
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
vue(),
|
||||
AutoImport({
|
||||
imports: ["vue", "vue-router", "pinia"],
|
||||
dts: "auto-imports.d.ts",
|
||||
eslintrc: {
|
||||
enabled: true,
|
||||
filepath: "./.eslintrc-auto-import.json",
|
||||
globalsPropValue: true
|
||||
},
|
||||
fs: {
|
||||
allow: [
|
||||
projectRoot,
|
||||
localTimiWebRoot,
|
||||
localTimiWebApiRoot,
|
||||
localTimiTDesignMobileRoot
|
||||
]
|
||||
resolvers: [
|
||||
TDesignResolver({
|
||||
library: "mobile-vue"
|
||||
})
|
||||
]
|
||||
}),
|
||||
Components({
|
||||
dirs: ["src/components", "src/layout"],
|
||||
dts: "components.d.ts",
|
||||
resolvers: [
|
||||
TDesignResolver({
|
||||
library: "mobile-vue"
|
||||
}),
|
||||
(name) => {
|
||||
if (name === "CardContainer") {
|
||||
return {
|
||||
name: "CardContainer",
|
||||
from: "timi-tdesign-mobile"
|
||||
};
|
||||
}
|
||||
if (name === "CenterTips") {
|
||||
return {
|
||||
name: "CenterTips",
|
||||
from: "timi-web"
|
||||
};
|
||||
}
|
||||
}
|
||||
]
|
||||
})
|
||||
],
|
||||
css: {
|
||||
preprocessorOptions: {
|
||||
less: {
|
||||
javascriptEnabled: true
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
server: {
|
||||
port: 84,
|
||||
allowedHosts: [
|
||||
"gao.imyeyu.com"
|
||||
],
|
||||
/**
|
||||
* 调试产物(截图、CDP 脚本、Chrome 的 user-data-dir)不能被监听:
|
||||
* Chrome 运行时锁着里面的 SQLite,chokidar 一 watch 就 EBUSY 把 dev server 打挂。
|
||||
* 默认的 .git / node_modules 需要显式保留,因为这里的 ignored 会覆盖默认值。
|
||||
*/
|
||||
watch: {
|
||||
ignored: [
|
||||
"**/.git/**",
|
||||
"**/node_modules/**",
|
||||
"**/.debug-*",
|
||||
"**/.debug-*/**"
|
||||
]
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user