From 9d40ef519cd67787a1e41ed46afca53cb5383fef Mon Sep 17 00:00:00 2001 From: Adam Wathan Date: Sat, 17 Oct 2020 20:27:21 -0400 Subject: [PATCH] Remove default values from config that have default values even when not present at all --- __tests__/purgeUnusedStyles.test.js | 2 ++ __tests__/variantsAtRule.test.js | 4 +++- src/util/resolveConfig.js | 7 ++++++- stubs/defaultConfig.stub.js | 5 +---- 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/__tests__/purgeUnusedStyles.test.js b/__tests__/purgeUnusedStyles.test.js index 39ab1ec19..99b458e4c 100644 --- a/__tests__/purgeUnusedStyles.test.js +++ b/__tests__/purgeUnusedStyles.test.js @@ -58,6 +58,8 @@ const config = { }, } +delete config.presets + function assertPurged(result) { expect(result.css).not.toContain('.bg-red-600') expect(result.css).not.toContain('.w-1\\/3') diff --git a/__tests__/variantsAtRule.test.js b/__tests__/variantsAtRule.test.js index e0bc8942f..8c2528235 100644 --- a/__tests__/variantsAtRule.test.js +++ b/__tests__/variantsAtRule.test.js @@ -1,10 +1,12 @@ import postcss from 'postcss' import plugin from '../src/lib/substituteVariantsAtRules' import processPlugins from '../src/util/processPlugins' +import resolveConfig from '../src/util/resolveConfig' import config from '../stubs/defaultConfig.stub.js' function run(input, opts = config) { - return postcss([plugin(opts, processPlugins(opts.plugins, opts))]).process(input, { + const resolved = resolveConfig([opts]) + return postcss([plugin(resolved, processPlugins(resolved.plugins, resolved))]).process(input, { from: undefined, }) } diff --git a/src/util/resolveConfig.js b/src/util/resolveConfig.js index 1dc26b086..467d88e6a 100644 --- a/src/util/resolveConfig.js +++ b/src/util/resolveConfig.js @@ -220,6 +220,11 @@ export default function resolveConfig(configs) { corePlugins: resolveCorePlugins(allConfigs.map((c) => c.corePlugins)), plugins: resolvePluginLists(configs.map((c) => get(c, 'plugins', []))), }, - ...allConfigs + ...allConfigs, + { + prefix: '', + important: false, + separator: ':', + } ) } diff --git a/stubs/defaultConfig.stub.js b/stubs/defaultConfig.stub.js index 5e7b015dd..eb1a5c930 100644 --- a/stubs/defaultConfig.stub.js +++ b/stubs/defaultConfig.stub.js @@ -4,9 +4,7 @@ module.exports = { // purgeLayersByDefault: true, }, purge: [], - prefix: '', - important: false, - separator: ':', + presets: [], theme: { screens: { sm: '640px', @@ -818,6 +816,5 @@ module.exports = { transitionDelay: ['responsive'], animation: ['responsive'], }, - corePlugins: {}, plugins: [], }