diff --git a/src/tailwind.js b/src/tailwind.js index ca1f0cedf..aef6e0664 100644 --- a/src/tailwind.js +++ b/src/tailwind.js @@ -27,9 +27,23 @@ function findMixin(css, mixin) { } function addCustomMediaQueries(css, breakpoints) { + function buildMediaQuery(breakpoint) { + if (_.isString(breakpoint)) { + breakpoint = { min: breakpoint } + } + return _(breakpoint).toPairs().map(([feature, value]) => { + feature = _.get({ + min: 'min-width', + max: 'max-width', + }, feature, feature) + + return `(${feature}: ${value})` + }).join(' and ') + } + Object.keys(breakpoints).forEach(breakpoint => { const variableName = `--breakpoint-${breakpoint}` - const mediaQuery = `(min-width: ${breakpoints[breakpoint]})` + const mediaQuery = buildMediaQuery(breakpoints[breakpoint]) const rule = postcss.atRule({ name: 'custom-media', params: `${variableName} ${mediaQuery}`