Skip to content

Commit

Permalink
fix: improve error message when entry is missing w/ --target lib
Browse files Browse the repository at this point in the history
close #1051
  • Loading branch information
yyx990803 committed May 9, 2018
1 parent 6d1716e commit 8b4a112
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions packages/@vue/cli-service/lib/commands/build/resolveLibConfig.js
Original file line number Diff line number Diff line change
@@ -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()
Expand Down

0 comments on commit 8b4a112

Please sign in to comment.