| [9af201e] | 1 | import normalizeTailwindDirectives from './lib/normalizeTailwindDirectives'
|
|---|
| 2 | import expandTailwindAtRules from './lib/expandTailwindAtRules'
|
|---|
| 3 | import expandApplyAtRules from './lib/expandApplyAtRules'
|
|---|
| 4 | import evaluateTailwindFunctions from './lib/evaluateTailwindFunctions'
|
|---|
| 5 | import substituteScreenAtRules from './lib/substituteScreenAtRules'
|
|---|
| 6 | import resolveDefaultsAtRules from './lib/resolveDefaultsAtRules'
|
|---|
| 7 | import collapseAdjacentRules from './lib/collapseAdjacentRules'
|
|---|
| 8 | import collapseDuplicateDeclarations from './lib/collapseDuplicateDeclarations'
|
|---|
| 9 | import partitionApplyAtRules from './lib/partitionApplyAtRules'
|
|---|
| 10 | import { createContext } from './lib/setupContextUtils'
|
|---|
| 11 | import { issueFlagNotices } from './featureFlags'
|
|---|
| 12 |
|
|---|
| 13 | export default function processTailwindFeatures(setupContext) {
|
|---|
| 14 | return async function (root, result) {
|
|---|
| 15 | let { tailwindDirectives, applyDirectives } = normalizeTailwindDirectives(root)
|
|---|
| 16 |
|
|---|
| 17 | // Partition apply rules that are found in the css
|
|---|
| 18 | // itself.
|
|---|
| 19 | partitionApplyAtRules()(root, result)
|
|---|
| 20 |
|
|---|
| 21 | let context = setupContext({
|
|---|
| 22 | tailwindDirectives,
|
|---|
| 23 | applyDirectives,
|
|---|
| 24 | registerDependency(dependency) {
|
|---|
| 25 | result.messages.push({
|
|---|
| 26 | plugin: 'tailwindcss',
|
|---|
| 27 | parent: result.opts.from,
|
|---|
| 28 | ...dependency,
|
|---|
| 29 | })
|
|---|
| 30 | },
|
|---|
| 31 | createContext(tailwindConfig, changedContent) {
|
|---|
| 32 | return createContext(tailwindConfig, changedContent, root)
|
|---|
| 33 | },
|
|---|
| 34 | })(root, result)
|
|---|
| 35 |
|
|---|
| 36 | if (context.tailwindConfig.separator === '-') {
|
|---|
| 37 | throw new Error(
|
|---|
| 38 | "The '-' character cannot be used as a custom separator in JIT mode due to parsing ambiguity. Please use another character like '_' instead."
|
|---|
| 39 | )
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | issueFlagNotices(context.tailwindConfig)
|
|---|
| 43 |
|
|---|
| 44 | await expandTailwindAtRules(context)(root, result)
|
|---|
| 45 |
|
|---|
| 46 | // Partition apply rules that are generated by
|
|---|
| 47 | // addComponents, addUtilities and so on.
|
|---|
| 48 | partitionApplyAtRules()(root, result)
|
|---|
| 49 | expandApplyAtRules(context)(root, result)
|
|---|
| 50 | evaluateTailwindFunctions(context)(root, result)
|
|---|
| 51 | substituteScreenAtRules(context)(root, result)
|
|---|
| 52 | resolveDefaultsAtRules(context)(root, result)
|
|---|
| 53 | collapseAdjacentRules(context)(root, result)
|
|---|
| 54 | collapseDuplicateDeclarations(context)(root, result)
|
|---|
| 55 | }
|
|---|
| 56 | }
|
|---|