Skip to content

Commit

Permalink
feat: bail when user directly mutate output.publicPath
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jun 6, 2018
1 parent 7f36fdf commit 1732007
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
15 changes: 15 additions & 0 deletions packages/@vue/cli-service/lib/Service.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
1 change: 1 addition & 0 deletions packages/@vue/cli-service/lib/commands/build/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 1732007

Please sign in to comment.