Skip to content

Commit

Permalink
minor refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
brillout committed Feb 27, 2025
1 parent fba1dcb commit 1038074
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions vike/node/plugin/plugins/importUserCode/v1-design/getVikeConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,24 @@ function temp_interopVikeVitePlugin(
})
}

function sortConfigValueSources(configValueSources: ConfigValueSources, locationIdPage: LocationId | null) {
Object.entries(configValueSources).forEach(([configName, sources]) => {
sources
.sort((source1, source2) => {
if (!source1.plusFile || !source2.plusFile) return 0
const isGlobal = !locationIdPage
if (isGlobal) {
return sortAfterInheritanceOrderGlobal(source1.plusFile, source2.plusFile, null, configName)
} else {
return sortAfterInheritanceOrderPage(source1.plusFile, source2.plusFile, locationIdPage, configName)
}
})
// TODO/next-major: remove
// Interop with vike(options) in vite.config.js
// Make it least precedence
.sort(makeLast((source) => !source.plusFile))
})
}
function sortAfterInheritanceOrderPage(
plusFile1: PlusFile,
plusFile2: PlusFile,
Expand Down Expand Up @@ -911,25 +929,6 @@ function assertMetaUsage(
})
}

function sortConfigValueSources(configValueSources: ConfigValueSources, locationIdPage: LocationId | null) {
Object.entries(configValueSources).forEach(([configName, sources]) => {
sources
.sort((source1, source2) => {
if (!source1.plusFile || !source2.plusFile) return 0
const isGlobal = !locationIdPage
if (isGlobal) {
return sortAfterInheritanceOrderGlobal(source1.plusFile, source2.plusFile, null, configName)
} else {
return sortAfterInheritanceOrderPage(source1.plusFile, source2.plusFile, locationIdPage, configName)
}
})
// TODO/next-major: remove
// Interop with vike(options) in vite.config.js
// Make it least precedence
.sort(makeLast((source) => !source.plusFile))
})
}

// Test: https://github.com/vikejs/vike/blob/441a37c4c1a3b07bb8f6efb1d1f7be297a53974a/test/playground/vite.config.ts#L39
function applyEffectsConfVal(configValueSources: ConfigValueSources, configDefinitions: ConfigDefinitions) {
objectEntries(configDefinitions).forEach(([configNameEffect, configDefEffect]) => {
Expand Down

0 comments on commit 1038074

Please sign in to comment.