Skip to content

Commit

Permalink
Merge pull request tailwindlabs#520 from tailwindcss/process-tailwind…
Browse files Browse the repository at this point in the history
…-features-together

Process tailwind features together
  • Loading branch information
adamwathan authored Jul 16, 2018
2 parents 2574417 + 7201c4f commit 37493ed
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 14 deletions.
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const plugin = postcss.plugin('tailwind', config => {
plugins.push(registerConfigAsDependency(path.resolve(config)))
}

const lazyConfig = () => {
const getConfig = () => {
if (_.isUndefined(config)) {
return require('../defaultConfig')()
}
Expand All @@ -32,7 +32,7 @@ const plugin = postcss.plugin('tailwind', config => {

return postcss([
...plugins,
processTailwindFeatures(lazyConfig),
processTailwindFeatures(getConfig),
perfectionist({
cascade: true,
colorShorthand: true,
Expand Down
27 changes: 15 additions & 12 deletions src/processTailwindFeatures.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import _ from 'lodash'
import postcss from 'postcss'

import substituteTailwindAtRules from './lib/substituteTailwindAtRules'
Expand All @@ -10,17 +11,19 @@ import substituteClassApplyAtRules from './lib/substituteClassApplyAtRules'
import generateUtilities from './util/generateUtilities'
import processPlugins from './util/processPlugins'

export default function(lazyConfig) {
const config = lazyConfig()
const processedPlugins = processPlugins(config)
const utilities = generateUtilities(config, processedPlugins.utilities)
export default function(getConfig) {
return function(css) {
const config = getConfig()
const processedPlugins = processPlugins(config)
const utilities = generateUtilities(config, processedPlugins.utilities)

return postcss([
substituteTailwindAtRules(config, processedPlugins, utilities),
evaluateTailwindFunctions(config),
substituteVariantsAtRules(config, processedPlugins),
substituteResponsiveAtRules(config),
substituteScreenAtRules(config),
substituteClassApplyAtRules(config, utilities),
])
return postcss([
substituteTailwindAtRules(config, processedPlugins, utilities),
evaluateTailwindFunctions(config),
substituteVariantsAtRules(config, processedPlugins),
substituteResponsiveAtRules(config),
substituteScreenAtRules(config),
substituteClassApplyAtRules(config, utilities),
]).process(css, { from: _.get(css, 'source.input.file') })
}
}

0 comments on commit 37493ed

Please sign in to comment.