Skip to content

Commit bf9a304

Browse files
committed
test: only load vue.config.js if it exists
1 parent 3070364 commit bf9a304

File tree

1 file changed

+12
-10
lines changed

1 file changed

+12
-10
lines changed

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

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -163,17 +163,19 @@ module.exports = class Service {
163163
process.env.VUE_CLI_SERVICE_CONFIG_PATH ||
164164
path.resolve(this.context, 'vue.config.js')
165165
)
166-
try {
167-
fileConfig = require(configPath)
168-
if (!fileConfig || typeof fileConfig !== 'object') {
169-
error(
170-
`Error loading ${chalk.bold('vue.config.js')}: should export an object.`
171-
)
172-
fileConfig = null
166+
if (fs.existsSync(configPath)) {
167+
try {
168+
fileConfig = require(configPath)
169+
if (!fileConfig || typeof fileConfig !== 'object') {
170+
error(
171+
`Error loading ${chalk.bold('vue.config.js')}: should export an object.`
172+
)
173+
fileConfig = null
174+
}
175+
} catch (e) {
176+
error(`Error loading ${chalk.bold('vue.config.js')}:`)
177+
throw e
173178
}
174-
} catch (e) {
175-
error(`Error loading ${chalk.bold('vue.config.js')}:`)
176-
throw e
177179
}
178180

179181
// package.vue

0 commit comments

Comments
 (0)