chore: 统一各 app 的构建目录

This commit is contained in:
wangxuefeng
2025-03-03 18:22:24 +08:00
parent 7fb8f5b7f8
commit 7c6a86edf6
14 changed files with 102 additions and 180 deletions

View File

@@ -1,5 +1,7 @@
# .env.development
VITE_NODE_ENV = pre
VITE_NODE_ENV = development
VITE_PORT = 10012
VITE_OA_BASEURL = https://oa-pre.shiyue.com

View File

@@ -1,4 +1,4 @@
import { defineConfig } from "@farmfe/core";
import { defineConfig, loadEnv } from "@farmfe/core";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import qiankun from "vite-plugin-qiankun";
@@ -7,40 +7,40 @@ import less from "@farmfe/js-plugin-less";
import Components from "unplugin-vue-components/vite";
import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
// const ENVS = {
// DEVELOPMENT: "development",
// PRODUCTION: "production",
// STAGING: "staging",
// TEST: "test",
// };
// @ts-ignore
export default defineConfig(({ mode }) => {
const env = loadEnv(mode, process.cwd(), ["VITE_"]);
return {
plugins: [less()],
vitePlugins: [
vue(),
vueJsx(),
qiankun("y-code-app", {
useDevMode: env.VITE_NODE_ENV === "development",
}) as any,
Components({
resolvers: [
AntDesignVueResolver({
importStyle: "less",
}),
],
}),
],
server: {
cors: true,
port: env.VITE_PORT,
},
// const env = process.env.NODE_ENV;
export default defineConfig({
plugins: [less()],
vitePlugins: [
vue(),
vueJsx(),
qiankun("y-code-app", {
useDevMode: process.env.DEV_ENV === "development",
}) as any,
Components({
resolvers: [
AntDesignVueResolver({
importStyle: "less",
}),
],
}),
],
server: {
cors: true,
port: 10012,
},
compilation: {
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
compilation: {
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
output: {
path: path.resolve(process.cwd(), "../../dist/y-code-v1"),
clean: true,
},
},
},
};
});

View File

@@ -4,17 +4,10 @@
"private": true,
"type": "module",
"scripts": {
"release": "semantic-release",
"dev": "cross-env farm start",
"dev": "cross-env farm start --mode development",
"build": "cross-env farm build --mode production",
"build:pre": "cross-env farm build --mode staging",
"build:pro": "cross-env farm build --mode production",
"preview": "cross-env farm preview",
"vite:dev": "cross-env DEV_ENV=development vite --mode staging",
"vite:pro": "cross-env DEV_ENV=development vite --mode production",
"vite:build:pre": "vite build --mode staging",
"vite:build:pro": "vite build --mode production",
"type-check": "vue-tsc --build --force",
"lint": "eslint . --ext .vue,.js,.jsx,.cjs,.mjs,.ts,.tsx,.cts,.mts --fix --ignore-path .gitignore",
"clean": "rimraf node_modules"
},
"dependencies": {

View File

@@ -1,83 +0,0 @@
import { fileURLToPath, URL } from "node:url";
import { defineConfig } from "vite";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
import Components from "unplugin-vue-components/vite";
import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
import qiankun from "vite-plugin-qiankun";
import yargsParser from "yargs-parser";
const argv = yargsParser(process.argv.slice(2));
console.log(process.env.DEV_ENV);
let base: string;
switch (argv.mode) {
case "staging":
case "test":
base = "https://custom-chart.shiyue.com/";
break;
case "production":
base = "https://custom-chart.shiyuegame.com/";
break;
default:
base = "http://localhost:8080/";
}
if (process.env.DEV_ENV === "development") {
base = "http://localhost:8080/";
}
// https://vitejs.dev/config/
export default defineConfig({
build: {
sourcemap: false,
rollupOptions: {
output: {
assetFileNames: "[name]-ycode-[hash:8].[ext]",
chunkFileNames: "[name]-ycode-[hash:8].js",
entryFileNames: "[name]-ycode-[hash:8].js",
},
},
},
css: {
devSourcemap: true,
preprocessorOptions: {
less: {
modifyVars: {
"ant-prefix": "ycode-ant",
},
},
},
},
plugins: [
vue(),
vueJsx(),
Components({
resolvers: [
AntDesignVueResolver({
importStyle: "less",
}),
],
}),
qiankun("y-code-app", {
useDevMode: process.env.DEV_ENV === "development",
}),
],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
base,
define: {
_BASE_HOST_: `'${base}'`,
},
optimizeDeps: {
force: true, // 强制重新预构建依赖
},
server: {
hmr: true,
host: "0.0.0.0",
port: 8080,
},
});