支持分环境打包

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 ./",
"format": "prettier --write \"**/*.{js,ts,vue,scss,html,md,json}\" --ignore-path .gitignore",
"test": "echo \"No test specified\" && exit 0",
"dev": "quasar dev",
"build": "quasar build",
"dev": "set NODE_ENV=dev&&quasar dev",
"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",
"sync": "node scripts/sync.cjs"
},
@ -19,14 +22,16 @@
"@pixi/graphics-extras": "^7.2.4",
"@quasar/extras": "^1.0.0",
"@stomp/stompjs": "^7.0.0",
"centrifuge": "^4.0.1",
"axios": "^1.2.1",
"centrifuge": "^4.0.1",
"dotenv": "^16.3.1",
"google-protobuf": "^3.21.2",
"js-base64": "^3.7.5",
"pinia": "^2.0.11",
"pixi-viewport": "^5.0.1",
"pixi.js": "^7.2.4",
"quasar": "^2.6.0",
"save-dev": "0.0.1-security",
"vue": "^3.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'],
node: 'node16',
},
env: require('./EnvParse.js')(),
vueRouterMode: 'history', // available values: 'hash', 'history'
vueRouterBase: BasePath,

View File

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