init project
This commit is contained in:
@@ -0,0 +1,88 @@
|
||||
import { fileURLToPath, URL } from "node:url";
|
||||
import { defineConfig, loadEnv } 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 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 useLocalTimiWebSource = useLocalTimiWeb && mode === "development";
|
||||
const useLocalTimiWebPublish = useLocalTimiWeb && mode !== "development";
|
||||
return {
|
||||
resolve: {
|
||||
dedupe: ["vue", "pinia", "vue-router"],
|
||||
alias: [
|
||||
{
|
||||
find: "@",
|
||||
replacement: fileURLToPath(new URL("./src", import.meta.url))
|
||||
},
|
||||
...(useLocalTimiWeb
|
||||
? [
|
||||
{
|
||||
find: /^timi-web$/,
|
||||
replacement: useLocalTimiWebSource
|
||||
? fileURLToPath(new URL("../timi-web/src/index.ts", import.meta.url))
|
||||
: fileURLToPath(new URL("../timi-web/dist/timi-web.mjs", import.meta.url))
|
||||
},
|
||||
{
|
||||
find: /^timi-web\/style\.css$/,
|
||||
replacement: useLocalTimiWebPublish
|
||||
? fileURLToPath(new URL("../timi-web/dist/timi-web.css", import.meta.url))
|
||||
: fileURLToPath(new URL("../timi-web/src/assets/style/timi-web.less", import.meta.url))
|
||||
}
|
||||
]
|
||||
: [])
|
||||
]
|
||||
},
|
||||
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"
|
||||
})
|
||||
]
|
||||
})
|
||||
],
|
||||
css: {
|
||||
preprocessorOptions: {
|
||||
less: {
|
||||
javascriptEnabled: true
|
||||
}
|
||||
}
|
||||
},
|
||||
server: {
|
||||
port: 84,
|
||||
allowedHosts: [
|
||||
"gao.imyeyu.dev"
|
||||
],
|
||||
fs: {
|
||||
allow: [
|
||||
projectRoot,
|
||||
localTimiWebRoot
|
||||
]
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
Reference in New Issue
Block a user