update env support
This commit is contained in:
1 parent
19facac317
commit
67f8e78bad
3 files changed
+51
-12
No files matched your search
+9
-2
@@ -2,8 +2,14 @@
|
||||
"name": "zhishuyun-academy",
|
||||
"version": "0.1.0",
|
||||
"scripts": {
|
||||
"start": "vite",
|
||||
"build": "vue-tsc --noEmit --skipLibCheck && vite build",
|
||||
"start": "cross-env NODE_ENV=$npm_config_env vite --host",
|
||||
"start:local": "npm run start --env=local",
|
||||
"start:test": "npm run start --env=test",
|
||||
"start:production": "npm run start --env=production",
|
||||
"build": "cross-env NODE_ENV=$npm_config_env vue-tsc --noEmit --skipLibCheck && vite build",
|
||||
"build:local": "npm run build --env=local",
|
||||
"build:test": "npm run build --env=test",
|
||||
"build:production": "npm run build --env=production",
|
||||
"serve": "vite preview",
|
||||
"lint": "npx eslint src --fix --ext .ts,.tsx,.vue,.js,.jsx",
|
||||
"prettier": "npx prettier --write ."
|
||||
@@ -36,6 +42,7 @@
|
||||
"@vitejs/plugin-vue": "^2.3.0",
|
||||
"@vue/compiler-sfc": "^3.0.5",
|
||||
"autoprefixer": "^10.3.3",
|
||||
"cross-env": "^7.0.3",
|
||||
"eslint": "^7.32.0",
|
||||
"eslint-config-prettier": "^8.5.0",
|
||||
"eslint-config-standard": "^16.0.3",
|
||||
|
||||
+34
-9
@@ -5,6 +5,31 @@ import { string } from 'rollup-plugin-string';
|
||||
import * as path from 'path';
|
||||
import * as fs from 'fs';
|
||||
|
||||
const getAuthEndpoint = () => {
|
||||
console.log('process.env.NODE_ENV', process.env.NODE_ENV);
|
||||
switch (process.env.NODE_ENV) {
|
||||
case 'local':
|
||||
return 'http://localhost:8001';
|
||||
case 'test':
|
||||
return 'https://auth.test.zhishuyun.com';
|
||||
case 'production':
|
||||
default:
|
||||
return 'https://auth.zhishuyun.com';
|
||||
}
|
||||
};
|
||||
|
||||
const getAcademyEndpoint = () => {
|
||||
switch (process.env.NODE_ENV) {
|
||||
case 'local':
|
||||
return 'http://localhost:8002';
|
||||
case 'test':
|
||||
return 'https://auth.test.zhishuyun.com';
|
||||
case 'production':
|
||||
default:
|
||||
return 'https://auth.zhishuyun.com';
|
||||
}
|
||||
};
|
||||
|
||||
export default defineConfig({
|
||||
server: {
|
||||
// open: true,
|
||||
@@ -16,26 +41,26 @@ export default defineConfig({
|
||||
},
|
||||
proxy: {
|
||||
'/api/v1/me': {
|
||||
target: 'https://auth.test.zhishuyun.com',
|
||||
target: getAuthEndpoint(),
|
||||
changeOrigin: true
|
||||
},
|
||||
'/api/v1/token': {
|
||||
target: 'https://auth.test.zhishuyun.com',
|
||||
target: getAuthEndpoint(),
|
||||
changeOrigin: true
|
||||
},
|
||||
'/api': {
|
||||
target: 'http://localhost:8000',
|
||||
target: getAcademyEndpoint(),
|
||||
changeOrigin: true
|
||||
},
|
||||
'/static': {
|
||||
target: 'http://localhost:8000',
|
||||
target: getAcademyEndpoint(),
|
||||
changeOrigin: true
|
||||
},
|
||||
'/ws': {
|
||||
target: 'ws://localhost:8000',
|
||||
changeOrigin: true,
|
||||
ws: true
|
||||
}
|
||||
// '/ws': {
|
||||
// target: 'ws://localhost:8000',
|
||||
// changeOrigin: true,
|
||||
// ws: true
|
||||
// }
|
||||
}
|
||||
},
|
||||
plugins: [
|
||||
|
||||
@@ -880,7 +880,14 @@ cosmiconfig@^7.0.1:
|
||||
path-type "^4.0.0"
|
||||
yaml "^1.10.0"
|
||||
|
||||
cross-spawn@^7.0.2:
|
||||
cross-env@^7.0.3:
|
||||
version "7.0.3"
|
||||
resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-7.0.3.tgz#865264b29677dc015ba8418918965dd232fc54cf"
|
||||
integrity sha512-+/HKd6EgcQCJGh2PSjZuUitQBQynKor4wrFbRg4DtAgS1aWO+gU52xpH7M9ScGgXSYmAVS9bIJ8EzuaGw0oNAw==
|
||||
dependencies:
|
||||
cross-spawn "^7.0.1"
|
||||
|
||||
cross-spawn@^7.0.1, cross-spawn@^7.0.2:
|
||||
version "7.0.3"
|
||||
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-7.0.3.tgz#f73a85b9d5d41d045551c177e2882d4ac85728a6"
|
||||
integrity sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==
|
||||
|
||||
Reference in new issue
Block a user