Skip to content

Commit

Permalink
Feature(env): support multiple env build
Browse files Browse the repository at this point in the history
  • Loading branch information
Armour committed May 28, 2019
1 parent 99bc6b0 commit 463eaef
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 7 deletions.
1 change: 0 additions & 1 deletion .env

This file was deleted.

11 changes: 11 additions & 0 deletions .env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Base api
VUE_APP_BASE_API = '/dev-api'

# vue-cli uses the VUE_CLI_BABEL_TRANSPILE_MODULES environment variable,
# to control whether the babel-plugin-dynamic-import-node plugin is enabled.
# It only does one thing by converting all import() to require().
# This configuration can significantly increase the speed of hot updates,
# when you have a large number of pages.
# Detail: https://github.com/vuejs/vue-cli/blob/dev/packages/@vue/babel-preset-app/index.js

VUE_CLI_BABEL_TRANSPILE_MODULES = true
2 changes: 2 additions & 0 deletions .env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Base api
VUE_APP_BASE_API = '/prod-api'
6 changes: 6 additions & 0 deletions .env.staging
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Set to production for building optimization
NODE_ENV = production

# Base api
VUE_APP_BASE_API = '/stage-api'

2 changes: 1 addition & 1 deletion .github/main.workflow
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ action "Filters for GitHub Actions" {
action "Yarn build" {
uses = "borales/actions-yarn@master"
needs = ["Yarn install"]
args = "build"
args = "build:prod"
}

action "Deploy" {
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@
"author": "Chong Guo <[email protected]>",
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"build:prod": "vue-cli-service build",
"build:stage": "vue-cli-service build --mode staging",
"lint": "vue-cli-service lint",
"svg": "vsvg -s ./src/icons/svg -t ./src/icons/components --ext ts --es6",
"test:e2e": "vue-cli-service test:e2e",
"test:unit": "vue-cli-service test:unit"
"test:unit": "jest --clearCache && vue-cli-service test:unit"
},
"dependencies": {
"@tinymce/tinymce-vue": "^2.0.0",
Expand Down
6 changes: 3 additions & 3 deletions src/utils/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import { Message, MessageBox } from 'element-ui'
import { UserModule } from '@/store/modules/user'

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

// Request interceptors
Expand Down

0 comments on commit 463eaef

Please sign in to comment.