chore: 统一各 app 的构建目录
This commit is contained in:
parent
7fb8f5b7f8
commit
7c6a86edf6
@ -49,12 +49,7 @@ export default defineConfig(({ mode }) => {
|
|||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
outDir: path.resolve(process.cwd(), '../../dist/designer'), // 输出到根目录/designer
|
outDir: path.resolve(process.cwd(), '../../dist/designer'), // 输出到根目录/designer
|
||||||
emptyOutDir: true, // 构建前清空目录
|
emptyOutDir: true // 构建前清空目录
|
||||||
rollupOptions: {
|
|
||||||
input: {
|
|
||||||
main: path.resolve(__dirname, 'index.html') // 显式指定入口文件路径
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
@ -4,5 +4,7 @@ ENV = 'development'
|
|||||||
# 公共基础路径, 详见: https://cn.vitejs.dev/guide/build.html#public-base-path
|
# 公共基础路径, 详见: https://cn.vitejs.dev/guide/build.html#public-base-path
|
||||||
VITE_BASE_URL = /
|
VITE_BASE_URL = /
|
||||||
|
|
||||||
# base api url
|
# 前端可见变量(必须以 VITE_ 开头)
|
||||||
|
VITE_PORT = 10010
|
||||||
VITE_BASE_API_URL = 'https://custom-chart-pre-api.shiyue.com/'
|
VITE_BASE_API_URL = 'https://custom-chart-pre-api.shiyue.com/'
|
||||||
|
VITE_DEBUG_MODE = true
|
8
apps/platform/.env.staging
Normal file
8
apps/platform/.env.staging
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# 只在预发布模式中被载入
|
||||||
|
ENV = 'staging'
|
||||||
|
|
||||||
|
# 公共基础路径, 详见: https://cn.vitejs.dev/guide/build.html#public-base-path
|
||||||
|
VITE_BASE_URL = /
|
||||||
|
|
||||||
|
# base api url
|
||||||
|
VITE_BASE_API_URL = 'https://custom-chart-pre-api.shiyue.com/'
|
@ -13,10 +13,9 @@
|
|||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"preinstall": "npx only-allow pnpm",
|
"preinstall": "npx only-allow pnpm",
|
||||||
"serve": "npm run dev",
|
"dev": "cross-env vite --mode development",
|
||||||
"dev": "vite dev",
|
"build": "vite build --mode production",
|
||||||
"build": "rimraf dist && cross-env NODE_ENV=production vite build",
|
"build:staging": "vite build --mode staging",
|
||||||
"build:watch": "rimraf dist && cross-env NODE_ENV=production vite build --watch",
|
|
||||||
"preview": "vite preview",
|
"preview": "vite preview",
|
||||||
"preview:watch": "npm run build:watch && vite preview",
|
"preview:watch": "npm run build:watch && vite preview",
|
||||||
"clean:cache": "rimraf node_modules/.cache/ && rimraf node_modules/.vite",
|
"clean:cache": "rimraf node_modules/.cache/ && rimraf node_modules/.vite",
|
||||||
|
@ -17,8 +17,6 @@ import type { UserConfig, ConfigEnv } from 'vite';
|
|||||||
|
|
||||||
// console.log(DEV_SERVER_PORT);
|
// console.log(DEV_SERVER_PORT);
|
||||||
|
|
||||||
const CWD = process.cwd();
|
|
||||||
|
|
||||||
const __APP_INFO__ = {
|
const __APP_INFO__ = {
|
||||||
pkg,
|
pkg,
|
||||||
lastBuildTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
lastBuildTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||||
@ -27,12 +25,14 @@ const __APP_INFO__ = {
|
|||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default ({ command, mode }: ConfigEnv): UserConfig => {
|
export default ({ command, mode }: ConfigEnv): UserConfig => {
|
||||||
// 环境变量
|
// 环境变量
|
||||||
const { VITE_BASE_API_URL, VITE_BASE_URL, ENV } = loadEnv(mode, CWD);
|
const env = loadEnv(mode, process.cwd(), ['VITE_', 'VTJ_', 'SY_']);
|
||||||
const isDev = command === 'serve';
|
const isDev = command === 'serve';
|
||||||
|
|
||||||
return {
|
return {
|
||||||
define: {
|
define: {
|
||||||
__APP_INFO__: JSON.stringify(__APP_INFO__),
|
__APP_INFO__: JSON.stringify(__APP_INFO__),
|
||||||
|
// 注入环境变量到客户端
|
||||||
|
__APP_ENV__: JSON.stringify(env),
|
||||||
},
|
},
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: [
|
alias: [
|
||||||
@ -64,7 +64,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
|||||||
Http2Proxy(),
|
Http2Proxy(),
|
||||||
createSvgIconsPlugin({
|
createSvgIconsPlugin({
|
||||||
// Specify the icon folder to be cached
|
// Specify the icon folder to be cached
|
||||||
iconDirs: [resolve(CWD, 'src/assets/icons')],
|
iconDirs: [resolve(process.cwd(), 'src/assets/icons')],
|
||||||
// Specify symbolId format
|
// Specify symbolId format
|
||||||
symbolId: 'svg-icon-[dir]-[name]',
|
symbolId: 'svg-icon-[dir]-[name]',
|
||||||
}),
|
}),
|
||||||
@ -119,7 +119,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
outDir: 'dist',
|
outDir: resolve(process.cwd(), '../../dist/platform'), // 输出到根目录/designer
|
||||||
emptyOutDir: true,
|
emptyOutDir: true,
|
||||||
terserOptions: {
|
terserOptions: {
|
||||||
compress: {
|
compress: {
|
||||||
|
@ -4,5 +4,7 @@ ENV = 'development'
|
|||||||
# 公共基础路径, 详见: https://cn.vitejs.dev/guide/build.html#public-base-path
|
# 公共基础路径, 详见: https://cn.vitejs.dev/guide/build.html#public-base-path
|
||||||
VITE_BASE_URL = /
|
VITE_BASE_URL = /
|
||||||
|
|
||||||
# base api url
|
# 前端可见变量(必须以 VITE_ 开头)
|
||||||
|
VITE_PORT = 10010
|
||||||
VITE_BASE_API_URL = 'https://custom-chart-pre-api.shiyue.com/'
|
VITE_BASE_API_URL = 'https://custom-chart-pre-api.shiyue.com/'
|
||||||
|
VITE_DEBUG_MODE = true
|
8
apps/renderer/.env.staging
Normal file
8
apps/renderer/.env.staging
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
# 只在预发布模式中被载入
|
||||||
|
ENV = 'staging'
|
||||||
|
|
||||||
|
# 公共基础路径, 详见: https://cn.vitejs.dev/guide/build.html#public-base-path
|
||||||
|
VITE_BASE_URL = /
|
||||||
|
|
||||||
|
# base api url
|
||||||
|
VITE_BASE_API_URL = 'https://custom-chart-pre-api.shiyue.com/'
|
@ -1,23 +1,35 @@
|
|||||||
import { defineConfig } from "@farmfe/core";
|
import { defineConfig, loadEnv } from "@farmfe/core";
|
||||||
import vue from "@vitejs/plugin-vue";
|
import vue from "@vitejs/plugin-vue";
|
||||||
import mkcert from "vite-plugin-mkcert";
|
import mkcert from "vite-plugin-mkcert";
|
||||||
import Http2Proxy from "@sy/vite-plugin-http2-proxy";
|
import Http2Proxy from "@sy/vite-plugin-http2-proxy";
|
||||||
import path from "path";
|
import path from "path";
|
||||||
|
|
||||||
export default defineConfig({
|
// @ts-ignore
|
||||||
server: {
|
export default defineConfig(({ mode }) => {
|
||||||
// 本地开发时允许跨域访问该项目
|
const env = loadEnv(mode, process.cwd(), ["VITE_"]);
|
||||||
port: 10010,
|
|
||||||
cors: true,
|
return {
|
||||||
},
|
server: {
|
||||||
// @ts-ignore
|
port: env.VITE_PORT,
|
||||||
vitePlugins: [vue(), mkcert({ source: "coding" }), Http2Proxy()],
|
cors: true,
|
||||||
compilation: {
|
},
|
||||||
resolve: {
|
// @ts-ignore
|
||||||
alias: {
|
vitePlugins: [vue(), mkcert({ source: "coding" }), Http2Proxy()],
|
||||||
"@": path.resolve(process.cwd(), "src"),
|
compilation: {
|
||||||
$vtj: path.resolve(process.cwd(), ".vtj"),
|
resolve: {
|
||||||
|
alias: {
|
||||||
|
"@": path.resolve(process.cwd(), "src"),
|
||||||
|
$vtj: path.resolve(process.cwd(), ".vtj"),
|
||||||
|
},
|
||||||
|
},
|
||||||
|
define: {
|
||||||
|
// 注入环境变量到客户端
|
||||||
|
"process.env": JSON.stringify(env),
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
path: path.resolve(process.cwd(), "../../dist/renderer"),
|
||||||
|
clean: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
};
|
||||||
});
|
});
|
||||||
|
@ -3,9 +3,9 @@
|
|||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "farm dev",
|
"dev": "farm dev --mode development",
|
||||||
"start": "farm start",
|
"start": "farm start --mode production",
|
||||||
"build": "farm build",
|
"build": "farm build --mode production",
|
||||||
"preview": "farm preview",
|
"preview": "farm preview",
|
||||||
"clean:lock": "rimraf pnpm-lock.yaml && rimraf package.lock.json",
|
"clean:lock": "rimraf pnpm-lock.yaml && rimraf package.lock.json",
|
||||||
"clean:lib": "rimraf node_modules",
|
"clean:lib": "rimraf node_modules",
|
||||||
|
@ -1,16 +0,0 @@
|
|||||||
import { defineConfig } from "vite";
|
|
||||||
import http2Proxy from "@sy/vite-plugin-http2-proxy";
|
|
||||||
import mkcert from "vite-plugin-mkcert";
|
|
||||||
import VuePlugin from "@vitejs/plugin-vue";
|
|
||||||
|
|
||||||
export default defineConfig({
|
|
||||||
server: {
|
|
||||||
port: 10010,
|
|
||||||
},
|
|
||||||
plugins: [http2Proxy(), mkcert(), VuePlugin()],
|
|
||||||
esbuild: {
|
|
||||||
supported: {
|
|
||||||
"top-level-await": true,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
});
|
|
@ -1,5 +1,7 @@
|
|||||||
# .env.development
|
# .env.development
|
||||||
VITE_NODE_ENV = pre
|
VITE_NODE_ENV = development
|
||||||
|
|
||||||
|
VITE_PORT = 10012
|
||||||
|
|
||||||
VITE_OA_BASEURL = https://oa-pre.shiyue.com
|
VITE_OA_BASEURL = https://oa-pre.shiyue.com
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { defineConfig } from "@farmfe/core";
|
import { defineConfig, loadEnv } from "@farmfe/core";
|
||||||
import vue from "@vitejs/plugin-vue";
|
import vue from "@vitejs/plugin-vue";
|
||||||
import vueJsx from "@vitejs/plugin-vue-jsx";
|
import vueJsx from "@vitejs/plugin-vue-jsx";
|
||||||
import qiankun from "vite-plugin-qiankun";
|
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 Components from "unplugin-vue-components/vite";
|
||||||
import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
|
import { AntDesignVueResolver } from "unplugin-vue-components/resolvers";
|
||||||
|
|
||||||
// const ENVS = {
|
// @ts-ignore
|
||||||
// DEVELOPMENT: "development",
|
export default defineConfig(({ mode }) => {
|
||||||
// PRODUCTION: "production",
|
const env = loadEnv(mode, process.cwd(), ["VITE_"]);
|
||||||
// STAGING: "staging",
|
return {
|
||||||
// TEST: "test",
|
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;
|
compilation: {
|
||||||
|
resolve: {
|
||||||
export default defineConfig({
|
alias: {
|
||||||
plugins: [less()],
|
"@": path.resolve(__dirname, "./src"),
|
||||||
vitePlugins: [
|
},
|
||||||
vue(),
|
},
|
||||||
vueJsx(),
|
output: {
|
||||||
qiankun("y-code-app", {
|
path: path.resolve(process.cwd(), "../../dist/y-code-v1"),
|
||||||
useDevMode: process.env.DEV_ENV === "development",
|
clean: true,
|
||||||
}) as any,
|
|
||||||
Components({
|
|
||||||
resolvers: [
|
|
||||||
AntDesignVueResolver({
|
|
||||||
importStyle: "less",
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
server: {
|
|
||||||
cors: true,
|
|
||||||
port: 10012,
|
|
||||||
},
|
|
||||||
compilation: {
|
|
||||||
resolve: {
|
|
||||||
alias: {
|
|
||||||
"@": path.resolve(__dirname, "./src"),
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
},
|
};
|
||||||
});
|
});
|
||||||
|
@ -4,17 +4,10 @@
|
|||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"release": "semantic-release",
|
"dev": "cross-env farm start --mode development",
|
||||||
"dev": "cross-env farm start",
|
"build": "cross-env farm build --mode production",
|
||||||
"build:pre": "cross-env farm build --mode staging",
|
"build:pre": "cross-env farm build --mode staging",
|
||||||
"build:pro": "cross-env farm build --mode production",
|
|
||||||
"preview": "cross-env farm preview",
|
"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"
|
"clean": "rimraf node_modules"
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -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,
|
|
||||||
},
|
|
||||||
});
|
|
Loading…
x
Reference in New Issue
Block a user