From cb12c8a72cb6cb58c285445157c06654f020cab0 Mon Sep 17 00:00:00 2001 From: Mila <Mila@pollex.com.tw> Date: 星期三, 24 十一月 2021 09:09:49 +0800 Subject: [PATCH] add: 設定多個環境 .env 檔 (install @nuxtjs/dotenv / cross-env) --- PAMapp/.env.uat | 1 + PAMapp/package.json | 7 ++++++- PAMapp/nuxt.config.js | 7 +++---- PAMapp/.env.dev | 1 + 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/PAMapp/.env.dev b/PAMapp/.env.dev new file mode 100644 index 0000000..d98d903 --- /dev/null +++ b/PAMapp/.env.dev @@ -0,0 +1 @@ +BASE_URL='http://localhost:8080/api' \ No newline at end of file diff --git a/PAMapp/.env.uat b/PAMapp/.env.uat new file mode 100644 index 0000000..c15b919 --- /dev/null +++ b/PAMapp/.env.uat @@ -0,0 +1 @@ +BASE_URL='https://vtwlifeopensysuat.pru.intranet.asia/pamapi/api' \ No newline at end of file diff --git a/PAMapp/nuxt.config.js b/PAMapp/nuxt.config.js index 2ae6c63..b151e66 100644 --- a/PAMapp/nuxt.config.js +++ b/PAMapp/nuxt.config.js @@ -50,7 +50,9 @@ // https://go.nuxtjs.dev/typescript '@nuxt/typescript-build', '@nuxtjs/axios', - '@nuxtjs/style-resources' + '@nuxtjs/style-resources', + ['@nuxtjs/dotenv', { filename: '.env.' + process.env.ENV }], + ], // Modules: https://go.nuxtjs.dev/config-modules @@ -74,8 +76,5 @@ document.documentElement.scrollTop = 0; } } - }, - env: { - BASE_URL: 'http://localhost:8080/api' } } diff --git a/PAMapp/package.json b/PAMapp/package.json index cb9092c..1ddfc31 100644 --- a/PAMapp/package.json +++ b/PAMapp/package.json @@ -3,10 +3,13 @@ "version": "1.0.0", "private": true, "scripts": { - "dev": "nuxt", + "dev": "cross-env ENV=dev nuxt", + "uat": "cross-env ENV=uat nuxt", "build": "nuxt build", "start": "nuxt start", "generate": "nuxt generate", + "generate.dev": "cross-env ENV=dev nuxt generate", + "generate.uat": "cross-env ENV=uat nuxt generate", "test": "jest" }, "dependencies": { @@ -26,10 +29,12 @@ "devDependencies": { "@nuxt/types": "^2.15.8", "@nuxt/typescript-build": "^2.1.0", + "@nuxtjs/dotenv": "^1.4.1", "@types/lodash": "^4.14.176", "@vue/test-utils": "^1.2.2", "babel-core": "7.0.0-bridge.0", "babel-jest": "^27.3.0", + "cross-env": "^7.0.3", "fibers": "^5.0.0", "jest": "^27.3.0", "sass": "1.43.2", -- Gitblit v1.8.0