mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Merge plugins when resolving config (#2561)
This commit is contained in:
parent
62b1c37473
commit
038afedfac
@ -1856,3 +1856,33 @@ test('core plugin configurations stack', () => {
|
||||
corePlugins: ['float', 'padding', 'margin'],
|
||||
})
|
||||
})
|
||||
|
||||
test('plugins are merged', () => {
|
||||
const userConfig = {
|
||||
plugins: ['3'],
|
||||
}
|
||||
|
||||
const otherConfig = {
|
||||
plugins: ['2'],
|
||||
}
|
||||
|
||||
const defaultConfig = {
|
||||
plugins: ['1'],
|
||||
prefix: '',
|
||||
important: false,
|
||||
separator: ':',
|
||||
theme: {},
|
||||
variants: {},
|
||||
}
|
||||
|
||||
const result = resolveConfig([userConfig, otherConfig, defaultConfig])
|
||||
|
||||
expect(result).toMatchObject({
|
||||
prefix: '',
|
||||
important: false,
|
||||
separator: ':',
|
||||
theme: {},
|
||||
variants: {},
|
||||
plugins: ['1', '2', '3'],
|
||||
})
|
||||
})
|
||||
|
||||
@ -200,6 +200,14 @@ function resolveCorePlugins(corePluginConfigs) {
|
||||
return result
|
||||
}
|
||||
|
||||
function resolvePluginLists(pluginLists) {
|
||||
const result = [...pluginLists].reverse().reduce((resolved, pluginList) => {
|
||||
return [...resolved, ...pluginList]
|
||||
}, [])
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
export default function resolveConfig(configs) {
|
||||
const allConfigs = extractPluginConfigs(configs)
|
||||
|
||||
@ -210,6 +218,7 @@ export default function resolveConfig(configs) {
|
||||
),
|
||||
variants: resolveVariants(allConfigs.map(c => c.variants)),
|
||||
corePlugins: resolveCorePlugins(allConfigs.map(c => c.corePlugins)),
|
||||
plugins: resolvePluginLists(configs.map(c => get(c, 'plugins', []))),
|
||||
},
|
||||
...allConfigs
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user