diff --git a/packages/@vue/cli-service/lib/Service.js b/packages/@vue/cli-service/lib/Service.js index 9f3436b2a0..906a8993a9 100644 --- a/packages/@vue/cli-service/lib/Service.js +++ b/packages/@vue/cli-service/lib/Service.js @@ -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 } @@ -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) @@ -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] @@ -302,7 +302,7 @@ module.exports = class Service { return config } - loadUserOptions () { + async loadUserOptions () { // vue.config.js let fileConfig, pkgConfig, resolved, resolvedFrom const configPath = ( @@ -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() }