Skip to content

Commit 463eaef

Browse files
committed
Feature(env): support multiple env build
1 parent 99bc6b0 commit 463eaef

File tree

7 files changed

+26
-7
lines changed

7 files changed

+26
-7
lines changed

.env

-1
This file was deleted.

.env.development

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Base api
2+
VUE_APP_BASE_API = '/dev-api'
3+
4+
# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
5+
# to control whether the babel-plugin-dynamic-import-node plugin is enabled.
6+
# It only does one thing by converting all import() to require().
7+
# This configuration can significantly increase the speed of hot updates,
8+
# when you have a large number of pages.
9+
# Detail: https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/babel-preset-app/index.js
10+
11+
VUE_CLI_BABEL_TRANSPILE_MODULES = true

.env.production

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
# Base api
2+
VUE_APP_BASE_API = '/prod-api'

.env.staging

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Set to production for building optimization
2+
NODE_ENV = production
3+
4+
# Base api
5+
VUE_APP_BASE_API = '/stage-api'
6+

.github/main.workflow

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ action "Filters for GitHub Actions" {
1717
action "Yarn build" {
1818
uses = "borales/actions-yarn@master"
1919
needs = ["Yarn install"]
20-
args = "build"
20+
args = "build:prod"
2121
}
2222

2323
action "Deploy" {

package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,12 @@
55
"author": "Chong Guo <[email protected]>",
66
"scripts": {
77
"serve": "vue-cli-service serve",
8-
"build": "vue-cli-service build",
8+
"build:prod": "vue-cli-service build",
9+
"build:stage": "vue-cli-service build --mode staging",
910
"lint": "vue-cli-service lint",
1011
"svg": "vsvg -s ./src/icons/svg -t ./src/icons/components --ext ts --es6",
1112
"test:e2e": "vue-cli-service test:e2e",
12-
"test:unit": "vue-cli-service test:unit"
13+
"test:unit": "jest --clearCache && vue-cli-service test:unit"
1314
},
1415
"dependencies": {
1516
"@tinymce/tinymce-vue": "^2.0.0",

src/utils/request.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ import { Message, MessageBox } from 'element-ui'
33
import { UserModule } from '@/store/modules/user'
44

55
const service = axios.create({
6-
baseURL: process.env.VUE_APP_MOCK_API, // url = base url + request url
7-
withCredentials: true, // send cookies when cross-domain requests
8-
timeout: 5000
6+
baseURL: process.env.VUE_APP_BASE_API, // url = base url + request url
7+
timeout: 5000,
8+
// withCredentials: true // send cookies when cross-domain requests
99
})
1010

1111
// Request interceptors

0 commit comments

Comments
 (0)