Skip to content

Commit 8b4a112

Browse files
committed
fix: improve error message when entry is missing w/ --target lib
close #1051
1 parent 6d1716e commit 8b4a112

File tree

1 file changed

+20
-4
lines changed

1 file changed

+20
-4
lines changed

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,31 @@
1+
const fs = require('fs')
12
const path = require('path')
23

34
module.exports = (api, { entry, name }, options) => {
5+
// setting this disables app-only configs
6+
process.env.VUE_CLI_TARGET = 'lib'
7+
// inline all static asset files since there is no publicPath handling
8+
process.env.VUE_CLI_INLINE_LIMIT = Infinity
9+
10+
const { log, error } = require('@vue/cli-shared-utils')
11+
const abort = msg => {
12+
log()
13+
error(msg)
14+
process.exit(1)
15+
}
16+
17+
if (!fs.existsSync(api.resolve(entry))) {
18+
abort(
19+
`Failed to resolve lib entry: ${entry}${entry === `src/App.vue` ? ' (default)' : ''}. ` +
20+
`Make sure to specify the correct entry file.`
21+
)
22+
}
23+
424
const libName = (
525
name ||
626
api.service.pkg.name ||
727
path.basename(entry).replace(/\.(jsx?|vue)$/, '')
828
)
9-
// setting this disables app-only configs
10-
process.env.VUE_CLI_TARGET = 'lib'
11-
// inline all static asset files since there is no publicPath handling
12-
process.env.VUE_CLI_INLINE_LIMIT = Infinity
1329

1430
function genConfig (format, postfix = format, genHTML) {
1531
const config = api.resolveChainableWebpackConfig()

0 commit comments

Comments
 (0)