Skip to content

make vue.config.js async, this will let pull param #4954

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions packages/@vue/cli-service/lib/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ module.exports = class Service {
}
}

init (mode = process.env.VUE_CLI_MODE) {
async init (mode = process.env.VUE_CLI_MODE) {
if (this.initialized) {
return
}
Expand All @@ -71,7 +71,7 @@ module.exports = class Service {
this.loadEnv()

// load user config
const userOptions = this.loadUserOptions()
const userOptions = await this.loadUserOptions()
this.projectOptions = defaultsDeep(userOptions, defaults())

debug('vue:project-config')(this.projectOptions)
Expand Down Expand Up @@ -216,7 +216,7 @@ module.exports = class Service {
this.setPluginsToSkip(args)

// load env variables, load user config, apply plugins
this.init(mode)
await this.init(mode)

args._ = args._ || []
let command = this.commands[name]
Expand Down Expand Up @@ -302,7 +302,7 @@ module.exports = class Service {
return config
}

loadUserOptions () {
async loadUserOptions () {
// vue.config.js
let fileConfig, pkgConfig, resolved, resolvedFrom
const configPath = (
Expand All @@ -313,6 +313,10 @@ module.exports = class Service {
try {
fileConfig = require(configPath)

if( fileConfig instanceof Promise){
fileConfig = await fileConfig
}

if (typeof fileConfig === 'function') {
fileConfig = fileConfig()
}
Expand Down