mirror of
https://github.com/tailwindlabs/tailwindcss.git
synced 2025-12-08 21:36:08 +00:00
* WIP * WIP * Finish combining JIT and AOT plugins Still lots of clean up that can be done in some of the more complex ones, but at least it's one file per plugin now. * Remove unused import * Fix AOT generation bugs * Move corePlugins/index.js to corePlugins.js * Convert JIT files to ESM * Move tests * Reorder core plugins to match JIT order * Update AOT apply tests * Unify utils * Combine plugin lists to one single source of truth * Finish resolving merge conflicts, fix tests Co-authored-by: Adam Wathan <adam.wathan@gmail.com>
44 lines
1.1 KiB
JavaScript
44 lines
1.1 KiB
JavaScript
import _ from 'lodash'
|
|
import escapeClassName from '../../src/util/escapeClassName'
|
|
|
|
export default function (plugin, config) {
|
|
const addedUtilities = []
|
|
|
|
const getConfigValue = (path, defaultValue) => _.get(config, path, defaultValue)
|
|
const pluginApi = {
|
|
config: getConfigValue,
|
|
e: escapeClassName,
|
|
theme: (path, defaultValue) => getConfigValue(`theme.${path}`, defaultValue),
|
|
variants: (path, defaultValue) => {
|
|
if (_.isArray(config.variants)) {
|
|
return config.variants
|
|
}
|
|
|
|
return getConfigValue(`variants.${path}`, defaultValue)
|
|
},
|
|
addUtilities(utilities, variants) {
|
|
addedUtilities.push([utilities, variants])
|
|
},
|
|
corePlugins(corePlugin) {
|
|
if (config.corePlugins === undefined) {
|
|
return false
|
|
}
|
|
|
|
if (Array.isArray(config.corePlugins)) {
|
|
return config.corePlugins.includes(corePlugin)
|
|
}
|
|
|
|
return config.corePlugins[corePlugin] !== false
|
|
},
|
|
}
|
|
|
|
plugin(pluginApi)
|
|
|
|
return {
|
|
utilities: addedUtilities.map(([utilities, variants]) => [
|
|
_.merge({}, ..._.castArray(utilities)),
|
|
variants,
|
|
]),
|
|
}
|
|
}
|