mirror of
https://github.com/chansee97/nova-admin.git
synced 2025-04-06 03:57:54 +08:00
refactor(porject): 迁移代理配置至config
This commit is contained in:
parent
65db1d063e
commit
bb54075e91
@ -11,5 +11,4 @@ lib
|
|||||||
/docs
|
/docs
|
||||||
.vscode
|
.vscode
|
||||||
.local
|
.local
|
||||||
!.env-config.ts
|
|
||||||
components.d.ts
|
components.d.ts
|
||||||
|
@ -1,2 +1,3 @@
|
|||||||
export * from './sdk';
|
export * from './sdk';
|
||||||
export * from './service';
|
export * from './service';
|
||||||
|
export * from './env';
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import { getServiceEnvConfig } from '~/.env-config';
|
import { getServiceEnvConfig } from '@/config';
|
||||||
import { createRequest } from './request';
|
import { createRequest } from './request';
|
||||||
|
|
||||||
const { url, urlPattern } = getServiceEnvConfig(import.meta.env);
|
const { url, urlPattern } = getServiceEnvConfig(import.meta.env);
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { defineConfig, loadEnv, ConfigEnv } from 'vite';
|
import { defineConfig, loadEnv, ConfigEnv } from 'vite';
|
||||||
import { createViteProxy, setVitePlugins } from './build';
|
import { createViteProxy, setVitePlugins } from './build';
|
||||||
import { resolve } from 'path';
|
import { resolve } from 'path';
|
||||||
import { getServiceEnvConfig } from './.env-config';
|
import { getServiceEnvConfig } from './src/config';
|
||||||
|
|
||||||
// 当前执行node命令时文件夹的地址(工作目录)
|
// 当前执行node命令时文件夹的地址(工作目录)
|
||||||
const rootPath: string = resolve(process.cwd());
|
const rootPath: string = resolve(process.cwd());
|
||||||
@ -9,39 +9,39 @@ const srcPath = `${rootPath}/src`;
|
|||||||
|
|
||||||
// https://vitejs.dev/config/
|
// https://vitejs.dev/config/
|
||||||
export default defineConfig(({ command, mode }: ConfigEnv) => {
|
export default defineConfig(({ command, mode }: ConfigEnv) => {
|
||||||
// 在开发环境下 command 的值为 serve 生产环境下为 build
|
// 在开发环境下 command 的值为 serve 生产环境下为 build
|
||||||
|
|
||||||
// 根据当前工作目录中的 `mode` 加载 .env 文件
|
// 根据当前工作目录中的 `mode` 加载 .env 文件
|
||||||
// 设置第三个参数为 '' 来加载所有环境变量,而不管是否有 `VITE_` 前缀。
|
// 设置第三个参数为 '' 来加载所有环境变量,而不管是否有 `VITE_` 前缀。
|
||||||
const env = loadEnv(mode, process.cwd(), '') as unknown as ImportMetaEnv;
|
const env = loadEnv(mode, process.cwd(), '') as unknown as ImportMetaEnv;
|
||||||
|
|
||||||
const isOpenProxy = env.VITE_HTTP_PROXY === 'Y';
|
const isOpenProxy = env.VITE_HTTP_PROXY === 'Y';
|
||||||
const envConfig = getServiceEnvConfig(env);
|
const envConfig = getServiceEnvConfig(env);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
base: env.VITE_BASE_URL,
|
base: env.VITE_BASE_URL,
|
||||||
plugins: setVitePlugins(env),
|
plugins: setVitePlugins(env),
|
||||||
resolve: {
|
resolve: {
|
||||||
alias: {
|
alias: {
|
||||||
'~': rootPath,
|
'~': rootPath,
|
||||||
'@': srcPath,
|
'@': srcPath,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
host: '0.0.0.0',
|
host: '0.0.0.0',
|
||||||
port: 3000,
|
port: 3000,
|
||||||
open: true,
|
open: true,
|
||||||
proxy: createViteProxy(isOpenProxy, envConfig),
|
proxy: createViteProxy(isOpenProxy, envConfig),
|
||||||
},
|
},
|
||||||
preview: {
|
preview: {
|
||||||
port: 5211,
|
port: 5211,
|
||||||
},
|
},
|
||||||
build: {
|
build: {
|
||||||
reportCompressedSize: false, // 启用/禁用 gzip 压缩大小报告
|
reportCompressedSize: false, // 启用/禁用 gzip 压缩大小报告
|
||||||
sourcemap: false, // 构建后是否生成 source map 文件
|
sourcemap: false, // 构建后是否生成 source map 文件
|
||||||
},
|
},
|
||||||
optimizeDeps: {
|
optimizeDeps: {
|
||||||
include: ['echarts', 'md-editor-v3', '@wangeditor/editor', '@wangeditor/editor-for-vue'],
|
include: ['echarts', 'md-editor-v3', '@wangeditor/editor', '@wangeditor/editor-for-vue'],
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user