mirror of
https://github.com/soybeanjs/soybean-admin.git
synced 2025-10-01 07:36:41 +08:00
Merge 8ffcfa73ed
into 810398abb8
This commit is contained in:
commit
c36aace409
@ -9,6 +9,12 @@ const serviceEnv: ServiceEnv = {
|
|||||||
secondUrl: 'http://localhost:8081',
|
secondUrl: 'http://localhost:8081',
|
||||||
secondUrlPattern: '/second-url-pattern'
|
secondUrlPattern: '/second-url-pattern'
|
||||||
},
|
},
|
||||||
|
uat: {
|
||||||
|
url: 'http://localhost:8080',
|
||||||
|
urlPattern: '/url-pattern',
|
||||||
|
secondUrl: 'http://localhost:8081',
|
||||||
|
secondUrlPattern: '/second-url-pattern'
|
||||||
|
},
|
||||||
test: {
|
test: {
|
||||||
url: 'http://localhost:8080',
|
url: 'http://localhost:8080',
|
||||||
urlPattern: '/url-pattern',
|
urlPattern: '/url-pattern',
|
||||||
|
@ -1 +1,2 @@
|
|||||||
VITE_HTTP_PROXY=Y
|
VITE_HTTP_PROXY=Y
|
||||||
|
VITE_MODE=DEV_DEV_DEV
|
||||||
|
@ -4,3 +4,4 @@ VITE_COMPRESS=N
|
|||||||
|
|
||||||
# gzip | brotliCompress | deflate | deflateRaw
|
# gzip | brotliCompress | deflate | deflateRaw
|
||||||
VITE_COMPRESS_TYPE=gzip
|
VITE_COMPRESS_TYPE=gzip
|
||||||
|
VITE_MODE=PRD_PRD_PRD
|
||||||
|
@ -9,24 +9,13 @@ import unplugin from './unplugin';
|
|||||||
import mock from './mock';
|
import mock from './mock';
|
||||||
import visualizer from './visualizer';
|
import visualizer from './visualizer';
|
||||||
import compress from './compress';
|
import compress from './compress';
|
||||||
import pwa from './pwa';
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* vite插件
|
* vite插件
|
||||||
* @param viteEnv - 环境变量配置
|
* @param viteEnv - 环境变量配置
|
||||||
*/
|
*/
|
||||||
export function setupVitePlugins(viteEnv: ImportMetaEnv): (PluginOption | PluginOption[])[] {
|
export function setupVitePlugins(viteEnv: ImportMetaEnv): (PluginOption | PluginOption[])[] {
|
||||||
const plugins = [
|
const plugins = [vue(), vueJsx(), html(viteEnv), ...unplugin(viteEnv), unocss(), mock, progress(), routerPage()];
|
||||||
vue(),
|
|
||||||
vueJsx(),
|
|
||||||
html(viteEnv),
|
|
||||||
...unplugin(viteEnv),
|
|
||||||
unocss(),
|
|
||||||
mock,
|
|
||||||
progress(),
|
|
||||||
routerPage(),
|
|
||||||
pwa()
|
|
||||||
];
|
|
||||||
|
|
||||||
if (viteEnv.VITE_VISUALIZER === 'Y') {
|
if (viteEnv.VITE_VISUALIZER === 'Y') {
|
||||||
plugins.push(visualizer as PluginOption);
|
plugins.push(visualizer as PluginOption);
|
||||||
|
@ -1,31 +0,0 @@
|
|||||||
import { VitePWA } from 'vite-plugin-pwa';
|
|
||||||
|
|
||||||
export default function setupVitePwa() {
|
|
||||||
return VitePWA({
|
|
||||||
registerType: 'autoUpdate',
|
|
||||||
includeAssets: ['favicon.ico'],
|
|
||||||
manifest: {
|
|
||||||
name: 'SoybeanAdmin',
|
|
||||||
short_name: 'SoybeanAdmin',
|
|
||||||
theme_color: '#fff',
|
|
||||||
icons: [
|
|
||||||
{
|
|
||||||
src: '/logo.png',
|
|
||||||
sizes: '192x192',
|
|
||||||
type: 'image/png'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
src: '/logo.png',
|
|
||||||
sizes: '512x512',
|
|
||||||
type: 'image/png'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
src: '/logo.png',
|
|
||||||
sizes: '512x512',
|
|
||||||
type: 'image/png',
|
|
||||||
purpose: 'any maskable'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
@ -36,6 +36,7 @@
|
|||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"dev": "cross-env VITE_SERVICE_ENV=dev vite",
|
"dev": "cross-env VITE_SERVICE_ENV=dev vite",
|
||||||
|
"dev:uat": "cross-env VITE_SERVICE_ENV=uat vite --mode uat",
|
||||||
"dev:test": "cross-env VITE_SERVICE_ENV=test vite",
|
"dev:test": "cross-env VITE_SERVICE_ENV=test vite",
|
||||||
"dev:prod": "cross-env VITE_SERVICE_ENV=prod vite",
|
"dev:prod": "cross-env VITE_SERVICE_ENV=prod vite",
|
||||||
"build": "npm run typecheck && cross-env VITE_SERVICE_ENV=prod vite build",
|
"build": "npm run typecheck && cross-env VITE_SERVICE_ENV=prod vite build",
|
||||||
@ -122,7 +123,6 @@
|
|||||||
"vite-plugin-html": "^3.2.0",
|
"vite-plugin-html": "^3.2.0",
|
||||||
"vite-plugin-mock": "^2.9.6",
|
"vite-plugin-mock": "^2.9.6",
|
||||||
"vite-plugin-progress": "^0.0.6",
|
"vite-plugin-progress": "^0.0.6",
|
||||||
"vite-plugin-pwa": "^0.13.3",
|
|
||||||
"vite-plugin-svg-icons": "^2.0.1",
|
"vite-plugin-svg-icons": "^2.0.1",
|
||||||
"vue-tsc": "^1.0.9",
|
"vue-tsc": "^1.0.9",
|
||||||
"zx": "^7.1.1"
|
"zx": "^7.1.1"
|
||||||
|
1440
pnpm-lock.yaml
1440
pnpm-lock.yaml
File diff suppressed because it is too large
Load Diff
@ -16,7 +16,7 @@
|
|||||||
import { dateZhCN, zhCN } from 'naive-ui';
|
import { dateZhCN, zhCN } from 'naive-ui';
|
||||||
import { subscribeStore, useThemeStore } from '@/store';
|
import { subscribeStore, useThemeStore } from '@/store';
|
||||||
import { useGlobalEvents } from '@/composables';
|
import { useGlobalEvents } from '@/composables';
|
||||||
|
console.log(import.meta.env);
|
||||||
const theme = useThemeStore();
|
const theme = useThemeStore();
|
||||||
|
|
||||||
subscribeStore();
|
subscribeStore();
|
||||||
|
3
src/typings/env.d.ts
vendored
3
src/typings/env.d.ts
vendored
@ -1,10 +1,11 @@
|
|||||||
/**
|
/**
|
||||||
*后台服务的环境类型
|
*后台服务的环境类型
|
||||||
* - dev: 后台开发环境
|
* - dev: 后台开发环境
|
||||||
|
* - uat: 后台uat环境
|
||||||
* - test: 后台测试环境
|
* - test: 后台测试环境
|
||||||
* - prod: 后台生产环境
|
* - prod: 后台生产环境
|
||||||
*/
|
*/
|
||||||
type ServiceEnvType = 'dev' | 'test' | 'prod';
|
type ServiceEnvType = 'dev' | 'test' | 'uat' | 'prod';
|
||||||
|
|
||||||
/** 后台服务的环境配置 */
|
/** 后台服务的环境配置 */
|
||||||
interface ServiceEnvConfig {
|
interface ServiceEnvConfig {
|
||||||
|
@ -3,6 +3,8 @@ import { createViteProxy, getRootPath, getSrcPath, setupVitePlugins, viteDefine
|
|||||||
import { getServiceEnvConfig } from './.env-config';
|
import { getServiceEnvConfig } from './.env-config';
|
||||||
|
|
||||||
export default defineConfig(configEnv => {
|
export default defineConfig(configEnv => {
|
||||||
|
// 加载 envDir 中的 .env 文件。默认情况下只有前缀为 VITE_ 会被加载,除非更改了 prefixes 配置。
|
||||||
|
|
||||||
const viteEnv = loadEnv(configEnv.mode, process.cwd()) as unknown as ImportMetaEnv;
|
const viteEnv = loadEnv(configEnv.mode, process.cwd()) as unknown as ImportMetaEnv;
|
||||||
|
|
||||||
const rootPath = getRootPath();
|
const rootPath = getRootPath();
|
||||||
@ -11,6 +13,10 @@ export default defineConfig(configEnv => {
|
|||||||
const isOpenProxy = viteEnv.VITE_HTTP_PROXY === 'Y';
|
const isOpenProxy = viteEnv.VITE_HTTP_PROXY === 'Y';
|
||||||
const envConfig = getServiceEnvConfig(viteEnv);
|
const envConfig = getServiceEnvConfig(viteEnv);
|
||||||
|
|
||||||
|
console.log(configEnv);
|
||||||
|
console.log(viteEnv);
|
||||||
|
console.log(envConfig);
|
||||||
|
|
||||||
return {
|
return {
|
||||||
base: viteEnv.VITE_BASE_URL,
|
base: viteEnv.VITE_BASE_URL,
|
||||||
resolve: {
|
resolve: {
|
||||||
|
Loading…
Reference in New Issue
Block a user