-
Notifications
You must be signed in to change notification settings - Fork 4.4k
/
Copy pathindex.js
59 lines (51 loc) · 1.85 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import postcss from 'postcss'
import evaluateTailwindFunctions from '../lib/evaluateTailwindFunctions'
import substituteScreenAtRules from '../lib/substituteScreenAtRules'
import normalizeTailwindDirectives from './lib/normalizeTailwindDirectives'
import setupContext from './lib/setupContext'
import removeLayerAtRules from './lib/removeLayerAtRules'
import expandTailwindAtRules from './lib/expandTailwindAtRules'
import expandApplyAtRules from './lib/expandApplyAtRules'
import collapseAdjacentRules from './lib/collapseAdjacentRules'
import { env } from './lib/sharedState'
export default function (configOrPath = {}) {
return [
env.DEBUG &&
function (root) {
console.log('\n')
console.time('JIT TOTAL')
return root
},
function (root, result) {
function registerDependency(fileName, type = 'dependency') {
result.messages.push({
type,
plugin: 'tailwindcss-jit',
parent: result.opts.from,
file: fileName,
})
}
let tailwindDirectives = normalizeTailwindDirectives(root)
let context = setupContext(configOrPath, tailwindDirectives)(result, root)
if (!env.TAILWIND_DISABLE_TOUCH) {
if (context.configPath !== null) {
registerDependency(context.configPath)
}
}
return postcss([
removeLayerAtRules(context, tailwindDirectives),
expandTailwindAtRules(context, registerDependency, tailwindDirectives),
expandApplyAtRules(context),
evaluateTailwindFunctions(context.tailwindConfig),
substituteScreenAtRules(context.tailwindConfig),
collapseAdjacentRules(context),
]).process(root, { from: undefined })
},
env.DEBUG &&
function (root) {
console.timeEnd('JIT TOTAL')
console.log('\n')
return root
},
].filter(Boolean)
}