chore: 工程优化与构建工具迁移为 farm

This commit is contained in:
wangxuefeng
2025-02-05 17:38:53 +08:00
parent dd8f7b52d2
commit 2cc93d4262
17 changed files with 6341 additions and 383 deletions

View File

@@ -1,12 +1,24 @@
import { defineConfig } from "@farmfe/core";
import vue from "@vitejs/plugin-vue";
import vueJsx from "@vitejs/plugin-vue-jsx";
// import { fileURLToPath, URL } from "node:url";
// import yargsParser from "yargs-parser";
import qiankun from "vite-plugin-qiankun";
import path from "path";
import less from "@farmfe/js-plugin-less";
import yargsParser from "yargs-parser";
import Components from "unplugin-vue-components/vite";
import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
// const argv = yargsParser(process.argv.slice(2));
// const ENVS = {
// DEVELOPMENT: "development",
// PRODUCTION: "production",
// STAGING: "staging",
// TEST: "test",
// };
console.log(process.env.DEV_ENV);
const argv = yargsParser(process.argv.slice(2));
const env = process.env.NODE_ENV;
console.log("argv", argv);
console.log("env", env);
// let base: string;
// switch (argv.mode) {
@@ -20,31 +32,36 @@ console.log(process.env.DEV_ENV);
// default:
// base = "http://localhost:8080/";
// }
// if (process.env.DEV_ENV === "development") {
// base = "http://localhost:8080/";
// }
// if (env === ENVS.DEVELOPMENT) base = "http://localhost:8080/";
// console.log("base", base);
export default defineConfig({
// compilation: {
// output: {
// path: "./dist",
// publicPath: base,
// filename: "[name]-ycode-[hash:8].[ext]",
// },
// sourcemap: false,
// },
vitePlugins: [vue(), vueJsx()],
// resolve: {
// alias: {
// "@": fileURLToPath(new URL("./src", import.meta.url)),
// },
// },
// define: {
// _BASE_HOST_: `'${base}'`,
// },
// server: {
// hmr: true,
// host: "0.0.0.0",
// port: 8080,
// },
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,
open: false,
port: 8080,
},
compilation: {
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
},
},
},
});