Skip to content

Commit 1732007

Browse files
committed
feat: bail when user directly mutate output.publicPath
1 parent 7f36fdf commit 1732007

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

packages/@vue/cli-service/lib/Service.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,21 @@ module.exports = class Service {
191191
config = merge(config, fn)
192192
}
193193
})
194+
195+
// check if the user has manually mutated output.publicPath
196+
const target = process.env.VUE_CLI_BUILD_TARGET
197+
const exceptionTargets = ['lib', 'wc', 'wc-async']
198+
if (
199+
!exceptionTargets.includes(target) &&
200+
config.output.publicPath !== this.projectOptions.baseUrl
201+
) {
202+
error(
203+
`Do not modify webpack output.publicPath directly. ` +
204+
`Use the "baseUrl" option in vue.config.js instead.`
205+
)
206+
process.exit(1)
207+
}
208+
194209
return config
195210
}
196211

packages/@vue/cli-service/lib/commands/build/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ module.exports = (api, options) => {
7171
}
7272

7373
// resolve raw webpack config
74+
process.env.VUE_CLI_BUILD_TARGET = args.target
7475
let webpackConfig
7576
if (args.target === 'lib') {
7677
webpackConfig = require('./resolveLibConfig')(api, args, options)

0 commit comments

Comments
 (0)