tailwindcss/src/lib/substituteScreenAtRules.js
Adam Wathan b2b95d5738 Register config file with Webpack for watching
This change tells Webpack (for those using it) that the config file
used should be tracked as a dependency and that the CSS should be
re-compiled if that config file changes.

It's careful to make sure the config file is loaded fresh every single
time to avoid weird caching issues.
2017-11-03 09:54:15 -04:00

22 lines
560 B
JavaScript

import _ from 'lodash'
import postcss from 'postcss'
import cloneNodes from '../util/cloneNodes'
import buildMediaQuery from '../util/buildMediaQuery'
export default function(config) {
return function(css) {
const options = config()
const rules = []
css.walkAtRules('screen', atRule => {
const screen = atRule.params
if (! _.has(options.screens, screen)) {
throw atRule.error(`No \`${screen}\` screen found.`)
}
atRule.name = 'media'
atRule.params = buildMediaQuery(options.screens[screen])
})
}
}