fix: improve error message when entry is missing w/ --target lib

close #1051
This commit is contained in:
Evan You
2018-05-09 17:29:56 -04:00
parent 6d1716e875
commit 8b4a112b31
@@ -1,15 +1,31 @@
const fs = require('fs')
const path = require('path')
module.exports = (api, { entry, name }, options) => {
// setting this disables app-only configs
process.env.VUE_CLI_TARGET = 'lib'
// inline all static asset files since there is no publicPath handling
process.env.VUE_CLI_INLINE_LIMIT = Infinity
const { log, error } = require('@vue/cli-shared-utils')
const abort = msg => {
log()
error(msg)
process.exit(1)
}
if (!fs.existsSync(api.resolve(entry))) {
abort(
`Failed to resolve lib entry: ${entry}${entry === `src/App.vue` ? ' (default)' : ''}. ` +
`Make sure to specify the correct entry file.`
)
}
const libName = (
name ||
api.service.pkg.name ||
path.basename(entry).replace(/\.(jsx?|vue)$/, '')
)
// setting this disables app-only configs
process.env.VUE_CLI_TARGET = 'lib'
// inline all static asset files since there is no publicPath handling
process.env.VUE_CLI_INLINE_LIMIT = Infinity
function genConfig (format, postfix = format, genHTML) {
const config = api.resolveChainableWebpackConfig()