diff --git a/packages/@vue/cli-service/lib/Service.js b/packages/@vue/cli-service/lib/Service.js index 06ce89a46..236815dbe 100644 --- a/packages/@vue/cli-service/lib/Service.js +++ b/packages/@vue/cli-service/lib/Service.js @@ -191,6 +191,21 @@ module.exports = class Service { config = merge(config, fn) } }) + + // check if the user has manually mutated output.publicPath + const target = process.env.VUE_CLI_BUILD_TARGET + const exceptionTargets = ['lib', 'wc', 'wc-async'] + if ( + !exceptionTargets.includes(target) && + config.output.publicPath !== this.projectOptions.baseUrl + ) { + error( + `Do not modify webpack output.publicPath directly. ` + + `Use the "baseUrl" option in vue.config.js instead.` + ) + process.exit(1) + } + return config } diff --git a/packages/@vue/cli-service/lib/commands/build/index.js b/packages/@vue/cli-service/lib/commands/build/index.js index 701ef6ff7..31d8e02b6 100644 --- a/packages/@vue/cli-service/lib/commands/build/index.js +++ b/packages/@vue/cli-service/lib/commands/build/index.js @@ -71,6 +71,7 @@ module.exports = (api, options) => { } // resolve raw webpack config + process.env.VUE_CLI_BUILD_TARGET = args.target let webpackConfig if (args.target === 'lib') { webpackConfig = require('./resolveLibConfig')(api, args, options)