Skip to content

Commit

Permalink
fix(config): fix features merge strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
haoziqaq committed Oct 15, 2022
1 parent 32e7dce commit c3a378f
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions packages/varlet-cli/src/config/varlet.config.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { pathExistsSync } from 'fs-extra'
import { merge } from 'lodash'
import { mergeWith } from 'lodash'
import { VARLET_CONFIG, SITE_CONFIG } from '../shared/constant'
import { outputFileSyncOnChange } from '../shared/fsUtils'
import { isArray } from '@varlet/shared'

interface VarletConfig {
/**
Expand Down Expand Up @@ -40,7 +41,15 @@ interface VarletConfig {
moduleCompatible?: Record<string, string>
}

export const defineConfig = (conf: VarletConfig) => conf
export function defineConfig(conf: VarletConfig) {
return conf
}

export function mergeStrategy(value: any, srcValue: any, key: string) {
if (key === 'features' && isArray(srcValue)) {
return srcValue
}
}

export function getVarletConfig(emit = false): any {
let config: any = {}
Expand All @@ -52,7 +61,7 @@ export function getVarletConfig(emit = false): any {
delete require.cache[require.resolve('../../varlet.default.config.js')]
const defaultConfig = require('../../varlet.default.config.js')

const mergedConfig = merge(defaultConfig, config)
const mergedConfig = mergeWith(defaultConfig, config, mergeStrategy)

if (emit) {
const source = JSON.stringify(mergedConfig, null, 2)
Expand Down

0 comments on commit c3a378f

Please sign in to comment.