mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
Fully parameterized, makes it easy to test module options behavior without testing against the entire default module list.
19 lines
591 B
JavaScript
19 lines
591 B
JavaScript
import _ from 'lodash'
|
|
import postcss from 'postcss'
|
|
import wrapWithVariants from '../util/wrapWithVariants'
|
|
|
|
export default function(modules, moduleOptions, generatorOptions = {}) {
|
|
modules.forEach(module => {
|
|
if (! _.has(moduleOptions, module.name)) {
|
|
throw new Error(`Module \`${module.name}\` is missing from moduleOptions.`)
|
|
}
|
|
})
|
|
|
|
return postcss.root({
|
|
nodes: _(modules)
|
|
.reject(module => moduleOptions[module.name] === false)
|
|
.flatMap(module => wrapWithVariants(module.generator(generatorOptions), moduleOptions[module.name]))
|
|
.value()
|
|
})
|
|
}
|