支持分环境打包

This commit is contained in:
tiger_zhou 2023-10-16 14:01:38 +08:00
parent e74fce268e
commit 64c3678d08
8 changed files with 28 additions and 8 deletions

2
.env.dev Normal file
View File

@ -0,0 +1,2 @@
API=192.168.3.233:9081
http=https

2
.env.local Normal file
View File

@ -0,0 +1,2 @@
API=localhost:9081
http=https

2
.env.prod Normal file
View File

@ -0,0 +1,2 @@
API=localhost:9081
http=https

2
.env.prod-test Normal file
View File

@ -0,0 +1,2 @@
API=localhost:9081
http=https

7
EnvParse.js Normal file
View File

@ -0,0 +1,7 @@
const DotEnv = require('dotenv')
const parsedEnv = DotEnv.config({ path: `.env.${process.env.NODE_ENV}` }).parsed
module.exports = function () {
return parsedEnv
}

View File

@ -9,8 +9,11 @@
"lint": "eslint --ext .js,.ts,.vue ./", "lint": "eslint --ext .js,.ts,.vue ./",
"format": "prettier --write \"**/*.{js,ts,vue,scss,html,md,json}\" --ignore-path .gitignore", "format": "prettier --write \"**/*.{js,ts,vue,scss,html,md,json}\" --ignore-path .gitignore",
"test": "echo \"No test specified\" && exit 0", "test": "echo \"No test specified\" && exit 0",
"dev": "quasar dev", "dev": "set NODE_ENV=dev&&quasar dev",
"build": "quasar build", "local": "set NODE_ENV=local&&quasar dev",
"build": "set NODE_ENV=prod&&quasar build",
"build-test": "set NODE_ENV=prod-test&&quasar build",
"protoc": "node scripts/proto.cjs", "protoc": "node scripts/proto.cjs",
"sync": "node scripts/sync.cjs" "sync": "node scripts/sync.cjs"
}, },
@ -19,14 +22,16 @@
"@pixi/graphics-extras": "^7.2.4", "@pixi/graphics-extras": "^7.2.4",
"@quasar/extras": "^1.0.0", "@quasar/extras": "^1.0.0",
"@stomp/stompjs": "^7.0.0", "@stomp/stompjs": "^7.0.0",
"centrifuge": "^4.0.1",
"axios": "^1.2.1", "axios": "^1.2.1",
"centrifuge": "^4.0.1",
"dotenv": "^16.3.1",
"google-protobuf": "^3.21.2", "google-protobuf": "^3.21.2",
"js-base64": "^3.7.5", "js-base64": "^3.7.5",
"pinia": "^2.0.11", "pinia": "^2.0.11",
"pixi-viewport": "^5.0.1", "pixi-viewport": "^5.0.1",
"pixi.js": "^7.2.4", "pixi.js": "^7.2.4",
"quasar": "^2.6.0", "quasar": "^2.6.0",
"save-dev": "0.0.1-security",
"vue": "^3.0.0", "vue": "^3.0.0",
"vue-router": "^4.0.0" "vue-router": "^4.0.0"
}, },

View File

@ -56,6 +56,7 @@ module.exports = configure(function (/* ctx */) {
browser: ['es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1'], browser: ['es2019', 'edge88', 'firefox78', 'chrome87', 'safari13.1'],
node: 'node16', node: 'node16',
}, },
env: require('./EnvParse.js')(),
vueRouterMode: 'history', // available values: 'hash', 'history' vueRouterMode: 'history', // available values: 'hash', 'history'
vueRouterBase: BasePath, vueRouterBase: BasePath,

View File

@ -1,9 +1,8 @@
function getHost(): string { function getHost(): string {
// return '192.168.3.7:9081'; const base_api = process.env.API;
// return '192.168.3.47:9081'; console.log(process.env);
// return '192.168.3.37:9081'; console.log(' load env :' + process.env.NODE_ENV);
// return '192.168.3.15:9081'; return base_api + '';
return '192.168.3.233:9081';
} }
export function getHttpBase() { export function getHttpBase() {