Skip to content

Commit d40d4b4

Browse files
committed
refactor: always extract vue.config.js
1 parent 6661ac2 commit d40d4b4

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

packages/@vue/cli/lib/Generator.js

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,8 @@ module.exports = class Generator {
2727
const api = new GeneratorAPI(id, this, options, rootOptions || {})
2828
apply(api, options, rootOptions)
2929
})
30-
// if the user has chosen so, extract configs from package.json into
31-
// dedicated files.
32-
if (extractConfigFiles) {
33-
this.extractConfigFiles()
34-
}
30+
// extract configs from package.json into dedicated files.
31+
this.extractConfigFiles(extractConfigFiles)
3532
}
3633

3734
async generate () {
@@ -44,15 +41,23 @@ module.exports = class Generator {
4441
await writeFileTree(this.context, this.files)
4542
}
4643

47-
extractConfigFiles () {
48-
for (const key in this.pkg) {
44+
extractConfigFiles (all) {
45+
const extract = key => {
4946
if (configMap[key]) {
5047
const value = this.pkg[key]
5148
const { transform, filename } = configMap[key]
5249
this.files[filename] = transform(value)
5350
delete this.pkg[key]
5451
}
5552
}
53+
if (all) {
54+
for (const key in this.pkg) {
55+
extract(key)
56+
}
57+
} else {
58+
// by default, extract vue.config.js
59+
extract('vue')
60+
}
5661
}
5762

5863
sortPkg () {

0 commit comments

Comments
 (0)