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

@@ -4,5 +4,7 @@ ENV = 'development'
# 公共基础路径, 详见: 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/'
# 前端可见变量(必须以 VITE_ 开头)
VITE_PORT = 10010
VITE_BASE_API_URL = 'https://custom-chart-pre-api.shiyue.com/'
VITE_DEBUG_MODE = true

View 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/'

View File

@@ -13,10 +13,9 @@
},
"scripts": {
"preinstall": "npx only-allow pnpm",
"serve": "npm run dev",
"dev": "vite dev",
"build": "rimraf dist && cross-env NODE_ENV=production vite build",
"build:watch": "rimraf dist && cross-env NODE_ENV=production vite build --watch",
"dev": "cross-env vite --mode development",
"build": "vite build --mode production",
"build:staging": "vite build --mode staging",
"preview": "vite preview",
"preview:watch": "npm run build:watch && vite preview",
"clean:cache": "rimraf node_modules/.cache/ && rimraf node_modules/.vite",

View File

@@ -17,8 +17,6 @@ import type { UserConfig, ConfigEnv } from 'vite';
// console.log(DEV_SERVER_PORT);
const CWD = process.cwd();
const __APP_INFO__ = {
pkg,
lastBuildTime: dayjs().format('YYYY-MM-DD HH:mm:ss'),
@@ -27,12 +25,14 @@ const __APP_INFO__ = {
// https://vitejs.dev/config/
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';
return {
define: {
__APP_INFO__: JSON.stringify(__APP_INFO__),
// 注入环境变量到客户端
__APP_ENV__: JSON.stringify(env),
},
resolve: {
alias: [
@@ -64,7 +64,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
Http2Proxy(),
createSvgIconsPlugin({
// Specify the icon folder to be cached
iconDirs: [resolve(CWD, 'src/assets/icons')],
iconDirs: [resolve(process.cwd(), 'src/assets/icons')],
// Specify symbolId format
symbolId: 'svg-icon-[dir]-[name]',
}),
@@ -119,7 +119,7 @@ export default ({ command, mode }: ConfigEnv): UserConfig => {
},
},
build: {
outDir: 'dist',
outDir: resolve(process.cwd(), '../../dist/platform'), // 输出到根目录/designer
emptyOutDir: true,
terserOptions: {
compress: {