tailwindcss 0.0.0-insiders.bd4dddd → 0.0.0-insiders.bda8421
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +1 -2
- package/README.md +13 -10
- package/colors.d.ts +3 -0
- package/defaultConfig.d.ts +3 -0
- package/defaultTheme.d.ts +4 -0
- package/lib/cli/build/deps.js +62 -0
- package/lib/cli/build/index.js +54 -0
- package/lib/cli/build/plugin.js +371 -0
- package/lib/cli/build/utils.js +88 -0
- package/lib/cli/build/watching.js +182 -0
- package/lib/cli/help/index.js +73 -0
- package/lib/cli/index.js +230 -0
- package/lib/cli/init/index.js +63 -0
- package/lib/cli-peer-dependencies.js +28 -7
- package/lib/cli.js +1 -741
- package/lib/corePluginList.js +17 -4
- package/lib/corePlugins.js +2503 -1839
- package/lib/css/preflight.css +32 -13
- package/lib/featureFlags.js +45 -28
- package/lib/index.js +1 -29
- package/lib/lib/cacheInvalidation.js +92 -0
- package/lib/lib/collapseAdjacentRules.js +30 -10
- package/lib/lib/collapseDuplicateDeclarations.js +13 -8
- package/lib/lib/content.js +214 -0
- package/lib/lib/defaultExtractor.js +240 -31
- package/lib/lib/evaluateTailwindFunctions.js +117 -50
- package/lib/lib/expandApplyAtRules.js +466 -230
- package/lib/lib/expandTailwindAtRules.js +156 -135
- package/lib/lib/findAtConfigPath.js +46 -0
- package/lib/lib/generateRules.js +554 -200
- package/lib/lib/getModuleDependencies.js +88 -37
- package/lib/lib/load-config.js +57 -0
- package/lib/lib/normalizeTailwindDirectives.js +39 -33
- package/lib/lib/offsets.js +355 -0
- package/lib/lib/partitionApplyAtRules.js +58 -0
- package/lib/lib/regex.js +74 -0
- package/lib/lib/remap-bitfield.js +89 -0
- package/lib/lib/resolveDefaultsAtRules.js +97 -69
- package/lib/lib/setupContextUtils.js +796 -341
- package/lib/lib/setupTrackingContext.js +66 -71
- package/lib/lib/sharedState.js +45 -14
- package/lib/lib/substituteScreenAtRules.js +14 -10
- package/lib/plugin.js +48 -0
- package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +21 -0
- package/lib/postcss-plugins/nesting/plugin.js +89 -0
- package/lib/processTailwindFeatures.js +37 -27
- package/lib/public/colors.js +272 -246
- package/lib/public/create-plugin.js +9 -5
- package/lib/public/default-config.js +10 -6
- package/lib/public/default-theme.js +10 -6
- package/lib/public/load-config.js +12 -0
- package/lib/public/resolve-config.js +11 -6
- package/lib/util/applyImportantSelector.js +36 -0
- package/lib/util/bigSign.js +6 -1
- package/lib/util/buildMediaQuery.js +13 -6
- package/lib/util/cloneDeep.js +9 -6
- package/lib/util/cloneNodes.js +44 -4
- package/lib/util/color.js +70 -53
- package/lib/util/colorNames.js +752 -0
- package/lib/util/configurePlugins.js +7 -2
- package/lib/util/createPlugin.js +8 -6
- package/lib/util/createUtilityPlugin.js +16 -16
- package/lib/util/dataTypes.js +295 -113
- package/lib/util/defaults.js +12 -7
- package/lib/util/escapeClassName.js +13 -8
- package/lib/util/escapeCommas.js +7 -2
- package/lib/util/flattenColorPalette.js +11 -12
- package/lib/util/formatVariantSelector.js +235 -151
- package/lib/util/getAllConfigs.js +33 -12
- package/lib/util/hashConfig.js +9 -4
- package/lib/util/isKeyframeRule.js +7 -2
- package/lib/util/isPlainObject.js +8 -3
- package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +25 -15
- package/lib/util/log.js +25 -15
- package/lib/util/nameClass.js +27 -10
- package/lib/util/negateValue.js +25 -8
- package/lib/util/normalizeConfig.js +127 -82
- package/lib/util/normalizeScreens.js +128 -11
- package/lib/util/parseAnimationValue.js +44 -40
- package/lib/util/parseBoxShadowValue.js +34 -23
- package/lib/util/parseDependency.js +39 -55
- package/lib/util/parseGlob.js +36 -0
- package/lib/util/parseObjectStyles.js +15 -10
- package/lib/util/pluginUtils.js +172 -69
- package/lib/util/prefixSelector.js +30 -12
- package/lib/util/pseudoElements.js +212 -0
- package/lib/util/removeAlphaVariables.js +31 -0
- package/lib/util/resolveConfig.js +101 -87
- package/lib/util/resolveConfigPath.js +30 -12
- package/lib/util/responsive.js +11 -6
- package/lib/util/splitAtTopLevelOnly.js +51 -0
- package/lib/util/tap.js +6 -1
- package/lib/util/toColorValue.js +7 -3
- package/lib/util/toPath.js +22 -4
- package/lib/util/transformThemeValue.js +40 -30
- package/lib/util/validateConfig.js +37 -0
- package/lib/util/validateFormalSyntax.js +26 -0
- package/lib/util/withAlphaVariable.js +27 -15
- package/lib/value-parser/LICENSE +22 -0
- package/lib/value-parser/README.md +3 -0
- package/lib/value-parser/index.d.js +2 -0
- package/lib/value-parser/index.js +22 -0
- package/lib/value-parser/parse.js +259 -0
- package/lib/value-parser/stringify.js +38 -0
- package/lib/value-parser/unit.js +86 -0
- package/lib/value-parser/walk.js +16 -0
- package/loadConfig.d.ts +4 -0
- package/loadConfig.js +2 -0
- package/nesting/index.d.ts +4 -0
- package/nesting/index.js +2 -12
- package/package.json +60 -55
- package/peers/index.js +75503 -55095
- package/plugin.d.ts +11 -0
- package/resolveConfig.d.ts +31 -0
- package/scripts/generate-types.js +104 -0
- package/scripts/release-channel.js +18 -0
- package/scripts/release-notes.js +21 -0
- package/scripts/type-utils.js +27 -0
- package/src/cli/build/deps.js +56 -0
- package/src/cli/build/index.js +49 -0
- package/src/cli/build/plugin.js +437 -0
- package/src/cli/build/utils.js +76 -0
- package/src/cli/build/watching.js +229 -0
- package/src/cli/help/index.js +70 -0
- package/src/cli/index.js +216 -0
- package/src/cli/init/index.js +79 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +1 -811
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +849 -243
- package/src/css/preflight.css +32 -13
- package/src/featureFlags.js +13 -9
- package/src/index.js +1 -28
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/content.js +249 -0
- package/src/lib/defaultExtractor.js +215 -33
- package/src/lib/evaluateTailwindFunctions.js +82 -8
- package/src/lib/expandApplyAtRules.js +512 -224
- package/src/lib/expandTailwindAtRules.js +102 -87
- package/src/lib/findAtConfigPath.js +48 -0
- package/src/lib/generateRules.js +541 -146
- package/src/lib/getModuleDependencies.js +70 -30
- package/src/lib/load-config.ts +44 -0
- package/src/lib/normalizeTailwindDirectives.js +1 -0
- package/src/lib/offsets.js +432 -0
- package/src/lib/partitionApplyAtRules.js +52 -0
- package/src/lib/regex.js +74 -0
- package/src/lib/remap-bitfield.js +82 -0
- package/src/lib/resolveDefaultsAtRules.js +55 -30
- package/src/lib/setupContextUtils.js +720 -190
- package/src/lib/setupTrackingContext.js +47 -61
- package/src/lib/sharedState.js +15 -4
- package/src/plugin.js +47 -0
- package/src/postcss-plugins/nesting/README.md +42 -0
- package/src/postcss-plugins/nesting/index.js +13 -0
- package/src/postcss-plugins/nesting/plugin.js +80 -0
- package/src/processTailwindFeatures.js +11 -4
- package/src/public/colors.js +22 -0
- package/src/public/default-config.js +1 -1
- package/src/public/default-theme.js +2 -2
- package/src/public/load-config.js +2 -0
- package/src/util/applyImportantSelector.js +27 -0
- package/src/util/buildMediaQuery.js +5 -3
- package/src/util/cloneNodes.js +40 -2
- package/src/util/color.js +39 -20
- package/src/util/colorNames.js +150 -0
- package/src/util/dataTypes.js +184 -26
- package/src/util/formatVariantSelector.js +272 -144
- package/src/util/getAllConfigs.js +21 -2
- package/src/util/isPlainObject.js +1 -1
- package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
- package/src/util/log.js +8 -8
- package/src/util/nameClass.js +4 -0
- package/src/util/negateValue.js +11 -3
- package/src/util/normalizeConfig.js +45 -6
- package/src/util/normalizeScreens.js +99 -4
- package/src/util/parseBoxShadowValue.js +4 -3
- package/src/util/parseDependency.js +37 -42
- package/src/util/parseGlob.js +24 -0
- package/src/util/pluginUtils.js +139 -24
- package/src/util/prefixSelector.js +31 -10
- package/src/util/pseudoElements.js +171 -0
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +70 -32
- package/src/util/resolveConfigPath.js +12 -1
- package/src/util/splitAtTopLevelOnly.js +52 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +13 -3
- package/src/util/validateConfig.js +26 -0
- package/src/util/validateFormalSyntax.js +34 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/src/value-parser/LICENSE +22 -0
- package/src/value-parser/README.md +3 -0
- package/src/value-parser/index.d.ts +177 -0
- package/src/value-parser/index.js +28 -0
- package/src/value-parser/parse.js +303 -0
- package/src/value-parser/stringify.js +41 -0
- package/src/value-parser/unit.js +118 -0
- package/src/value-parser/walk.js +18 -0
- package/stubs/.gitignore +1 -0
- package/stubs/.prettierrc.json +6 -0
- package/stubs/{defaultConfig.stub.js → config.full.js} +290 -178
- package/stubs/postcss.config.js +6 -0
- package/stubs/tailwind.config.cjs +2 -0
- package/stubs/tailwind.config.js +2 -0
- package/stubs/tailwind.config.ts +3 -0
- package/types/config.d.ts +376 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +298 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/generated/default-theme.d.ts +397 -0
- package/types/index.d.ts +11 -0
- package/CHANGELOG.md +0 -1959
- package/lib/constants.js +0 -37
- package/lib/lib/detectNesting.js +0 -34
- package/nesting/plugin.js +0 -41
- package/scripts/install-integrations.js +0 -27
- package/scripts/rebuildFixtures.js +0 -68
- package/src/constants.js +0 -17
- package/src/lib/detectNesting.js +0 -39
- /package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -0
- /package/stubs/{defaultPostCssConfig.stub.js → postcss.config.cjs} +0 -0
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
import path from 'path'
|
|
1
|
+
// @ts-check
|
|
3
2
|
|
|
4
|
-
import
|
|
5
|
-
import LRU from 'quick-lru'
|
|
6
|
-
import normalizePath from 'normalize-path'
|
|
3
|
+
import fs from 'fs'
|
|
4
|
+
import LRU from '@alloc/quick-lru'
|
|
7
5
|
|
|
8
6
|
import hash from '../util/hashConfig'
|
|
9
|
-
import getModuleDependencies from '../lib/getModuleDependencies'
|
|
10
|
-
|
|
11
7
|
import resolveConfig from '../public/resolve-config'
|
|
12
|
-
|
|
13
8
|
import resolveConfigPath from '../util/resolveConfigPath'
|
|
14
|
-
|
|
15
|
-
import { env } from './sharedState'
|
|
16
|
-
|
|
17
9
|
import { getContext, getFileModifiedMap } from './setupContextUtils'
|
|
18
10
|
import parseDependency from '../util/parseDependency'
|
|
11
|
+
import { validateConfig } from '../util/validateConfig.js'
|
|
12
|
+
import { parseCandidateFiles, resolvedChangedContent } from './content.js'
|
|
13
|
+
import { loadConfig } from '../lib/load-config'
|
|
14
|
+
import getModuleDependencies from './getModuleDependencies'
|
|
19
15
|
|
|
20
16
|
let configPathCache = new LRU({ maxSize: 100 })
|
|
21
17
|
|
|
@@ -26,9 +22,7 @@ function getCandidateFiles(context, tailwindConfig) {
|
|
|
26
22
|
return candidateFilesCache.get(context)
|
|
27
23
|
}
|
|
28
24
|
|
|
29
|
-
let candidateFiles = tailwindConfig
|
|
30
|
-
.filter((item) => typeof item === 'string')
|
|
31
|
-
.map((contentPath) => normalizePath(contentPath))
|
|
25
|
+
let candidateFiles = parseCandidateFiles(context, tailwindConfig)
|
|
32
26
|
|
|
33
27
|
return candidateFilesCache.set(context, candidateFiles).get(context)
|
|
34
28
|
}
|
|
@@ -41,7 +35,7 @@ function getTailwindConfig(configOrPath) {
|
|
|
41
35
|
let [prevConfig, prevConfigHash, prevDeps, prevModified] =
|
|
42
36
|
configPathCache.get(userConfigPath) || []
|
|
43
37
|
|
|
44
|
-
let newDeps = getModuleDependencies(userConfigPath)
|
|
38
|
+
let newDeps = getModuleDependencies(userConfigPath)
|
|
45
39
|
|
|
46
40
|
let modified = false
|
|
47
41
|
let newModified = new Map()
|
|
@@ -62,48 +56,18 @@ function getTailwindConfig(configOrPath) {
|
|
|
62
56
|
for (let file of newDeps) {
|
|
63
57
|
delete require.cache[file]
|
|
64
58
|
}
|
|
65
|
-
let newConfig = resolveConfig(
|
|
59
|
+
let newConfig = validateConfig(resolveConfig(loadConfig(userConfigPath)))
|
|
66
60
|
let newHash = hash(newConfig)
|
|
67
61
|
configPathCache.set(userConfigPath, [newConfig, newHash, newDeps, newModified])
|
|
68
62
|
return [newConfig, userConfigPath, newHash, newDeps]
|
|
69
63
|
}
|
|
70
64
|
|
|
71
65
|
// It's a plain object, not a path
|
|
72
|
-
let newConfig = resolveConfig(
|
|
73
|
-
configOrPath.config === undefined ? configOrPath : configOrPath.config
|
|
74
|
-
)
|
|
66
|
+
let newConfig = resolveConfig(configOrPath?.config ?? configOrPath ?? {})
|
|
75
67
|
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
|
|
80
|
-
let changedContent = context.tailwindConfig.content.files
|
|
81
|
-
.filter((item) => typeof item.raw === 'string')
|
|
82
|
-
.map(({ raw, extension = 'html' }) => ({ content: raw, extension }))
|
|
83
|
-
|
|
84
|
-
for (let changedFile of resolveChangedFiles(candidateFiles, fileModifiedMap)) {
|
|
85
|
-
let content = fs.readFileSync(changedFile, 'utf8')
|
|
86
|
-
let extension = path.extname(changedFile).slice(1)
|
|
87
|
-
changedContent.push({ content, extension })
|
|
88
|
-
}
|
|
89
|
-
return changedContent
|
|
90
|
-
}
|
|
68
|
+
newConfig = validateConfig(newConfig)
|
|
91
69
|
|
|
92
|
-
|
|
93
|
-
let changedFiles = new Set()
|
|
94
|
-
env.DEBUG && console.time('Finding changed files')
|
|
95
|
-
let files = fastGlob.sync(candidateFiles)
|
|
96
|
-
for (let file of files) {
|
|
97
|
-
let prevModified = fileModifiedMap.has(file) ? fileModifiedMap.get(file) : -Infinity
|
|
98
|
-
let modified = fs.statSync(file).mtimeMs
|
|
99
|
-
|
|
100
|
-
if (modified > prevModified) {
|
|
101
|
-
changedFiles.add(file)
|
|
102
|
-
fileModifiedMap.set(file, modified)
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
env.DEBUG && console.timeEnd('Finding changed files')
|
|
106
|
-
return changedFiles
|
|
70
|
+
return [newConfig, null, hash(newConfig), []]
|
|
107
71
|
}
|
|
108
72
|
|
|
109
73
|
// DISABLE_TOUCH = TRUE
|
|
@@ -112,7 +76,7 @@ function resolveChangedFiles(candidateFiles, fileModifiedMap) {
|
|
|
112
76
|
// source path), or set up a new one (including setting up watchers and registering
|
|
113
77
|
// plugins) then return it
|
|
114
78
|
export default function setupTrackingContext(configOrPath) {
|
|
115
|
-
return ({ tailwindDirectives, registerDependency
|
|
79
|
+
return ({ tailwindDirectives, registerDependency }) => {
|
|
116
80
|
return (root, result) => {
|
|
117
81
|
let [tailwindConfig, userConfigPath, tailwindConfigHash, configDependencies] =
|
|
118
82
|
getTailwindConfig(configOrPath)
|
|
@@ -125,7 +89,7 @@ export default function setupTrackingContext(configOrPath) {
|
|
|
125
89
|
// being part of this trigger too, but it's tough because it's impossible
|
|
126
90
|
// for a layer in one file to end up in the actual @tailwind rule in
|
|
127
91
|
// another file since independent sources are effectively isolated.
|
|
128
|
-
if (tailwindDirectives.size > 0
|
|
92
|
+
if (tailwindDirectives.size > 0) {
|
|
129
93
|
// Add current css file as a context dependencies.
|
|
130
94
|
contextDependencies.add(result.opts.from)
|
|
131
95
|
|
|
@@ -137,7 +101,7 @@ export default function setupTrackingContext(configOrPath) {
|
|
|
137
101
|
}
|
|
138
102
|
}
|
|
139
103
|
|
|
140
|
-
let [context] = getContext(
|
|
104
|
+
let [context, , mTimesToCommit] = getContext(
|
|
141
105
|
root,
|
|
142
106
|
result,
|
|
143
107
|
tailwindConfig,
|
|
@@ -146,6 +110,8 @@ export default function setupTrackingContext(configOrPath) {
|
|
|
146
110
|
contextDependencies
|
|
147
111
|
)
|
|
148
112
|
|
|
113
|
+
let fileModifiedMap = getFileModifiedMap(context)
|
|
114
|
+
|
|
149
115
|
let candidateFiles = getCandidateFiles(context, tailwindConfig)
|
|
150
116
|
|
|
151
117
|
// If there are no @tailwind or @apply rules, we don't consider this CSS file or it's
|
|
@@ -153,23 +119,36 @@ export default function setupTrackingContext(configOrPath) {
|
|
|
153
119
|
// We may want to think about `@layer` being part of this trigger too, but it's tough
|
|
154
120
|
// because it's impossible for a layer in one file to end up in the actual @tailwind rule
|
|
155
121
|
// in another file since independent sources are effectively isolated.
|
|
156
|
-
if (tailwindDirectives.size > 0
|
|
157
|
-
let fileModifiedMap = getFileModifiedMap(context)
|
|
158
|
-
|
|
122
|
+
if (tailwindDirectives.size > 0) {
|
|
159
123
|
// Add template paths as postcss dependencies.
|
|
160
|
-
for (let
|
|
161
|
-
let dependency
|
|
162
|
-
if (dependency) {
|
|
124
|
+
for (let contentPath of candidateFiles) {
|
|
125
|
+
for (let dependency of parseDependency(contentPath)) {
|
|
163
126
|
registerDependency(dependency)
|
|
164
127
|
}
|
|
165
128
|
}
|
|
166
129
|
|
|
167
|
-
|
|
130
|
+
let [changedContent, contentMTimesToCommit] = resolvedChangedContent(
|
|
168
131
|
context,
|
|
169
132
|
candidateFiles,
|
|
170
133
|
fileModifiedMap
|
|
171
|
-
)
|
|
172
|
-
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
for (let content of changedContent) {
|
|
137
|
+
context.changedContent.push(content)
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
// Add the mtimes of the content files to the commit list
|
|
141
|
+
// We can overwrite the existing values because unconditionally
|
|
142
|
+
// This is because:
|
|
143
|
+
// 1. Most of the files here won't be in the map yet
|
|
144
|
+
// 2. If they are that means it's a context dependency
|
|
145
|
+
// and we're reading this after the context. This means
|
|
146
|
+
// that the mtime we just read is strictly >= the context
|
|
147
|
+
// mtime. Unless the user / os is doing something weird
|
|
148
|
+
// in which the mtime would be going backwards. If that
|
|
149
|
+
// happens there's already going to be problems.
|
|
150
|
+
for (let [path, mtime] of contentMTimesToCommit.entries()) {
|
|
151
|
+
mTimesToCommit.set(path, mtime)
|
|
173
152
|
}
|
|
174
153
|
}
|
|
175
154
|
|
|
@@ -177,6 +156,13 @@ export default function setupTrackingContext(configOrPath) {
|
|
|
177
156
|
registerDependency({ type: 'dependency', file })
|
|
178
157
|
}
|
|
179
158
|
|
|
159
|
+
// "commit" the new modified time for all context deps
|
|
160
|
+
// We do this here because we want content tracking to
|
|
161
|
+
// read the "old" mtime even when it's a context dependency.
|
|
162
|
+
for (let [path, mtime] of mTimesToCommit.entries()) {
|
|
163
|
+
fileModifiedMap.set(path, mtime)
|
|
164
|
+
}
|
|
165
|
+
|
|
180
166
|
return context
|
|
181
167
|
}
|
|
182
168
|
}
|
package/src/lib/sharedState.js
CHANGED
|
@@ -1,10 +1,21 @@
|
|
|
1
|
-
export const env =
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
1
|
+
export const env =
|
|
2
|
+
typeof process !== 'undefined'
|
|
3
|
+
? {
|
|
4
|
+
NODE_ENV: process.env.NODE_ENV,
|
|
5
|
+
DEBUG: resolveDebug(process.env.DEBUG),
|
|
6
|
+
}
|
|
7
|
+
: {
|
|
8
|
+
NODE_ENV: 'production',
|
|
9
|
+
DEBUG: false,
|
|
10
|
+
}
|
|
11
|
+
|
|
5
12
|
export const contextMap = new Map()
|
|
6
13
|
export const configContextMap = new Map()
|
|
7
14
|
export const contextSourcesMap = new Map()
|
|
15
|
+
export const sourceHashMap = new Map()
|
|
16
|
+
export const NOT_ON_DEMAND = new String('*')
|
|
17
|
+
|
|
18
|
+
export const NONE = Symbol('__NONE__')
|
|
8
19
|
|
|
9
20
|
export function resolveDebug(debug) {
|
|
10
21
|
if (debug === undefined) {
|
package/src/plugin.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import setupTrackingContext from './lib/setupTrackingContext'
|
|
2
|
+
import processTailwindFeatures from './processTailwindFeatures'
|
|
3
|
+
import { env } from './lib/sharedState'
|
|
4
|
+
import { findAtConfigPath } from './lib/findAtConfigPath'
|
|
5
|
+
|
|
6
|
+
module.exports = function tailwindcss(configOrPath) {
|
|
7
|
+
return {
|
|
8
|
+
postcssPlugin: 'tailwindcss',
|
|
9
|
+
plugins: [
|
|
10
|
+
env.DEBUG &&
|
|
11
|
+
function (root) {
|
|
12
|
+
console.log('\n')
|
|
13
|
+
console.time('JIT TOTAL')
|
|
14
|
+
return root
|
|
15
|
+
},
|
|
16
|
+
async function (root, result) {
|
|
17
|
+
// Use the path for the `@config` directive if it exists, otherwise use the
|
|
18
|
+
// path for the file being processed
|
|
19
|
+
configOrPath = findAtConfigPath(root, result) ?? configOrPath
|
|
20
|
+
|
|
21
|
+
let context = setupTrackingContext(configOrPath)
|
|
22
|
+
|
|
23
|
+
if (root.type === 'document') {
|
|
24
|
+
let roots = root.nodes.filter((node) => node.type === 'root')
|
|
25
|
+
|
|
26
|
+
for (const root of roots) {
|
|
27
|
+
if (root.type === 'root') {
|
|
28
|
+
await processTailwindFeatures(context)(root, result)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
await processTailwindFeatures(context)(root, result)
|
|
36
|
+
},
|
|
37
|
+
env.DEBUG &&
|
|
38
|
+
function (root) {
|
|
39
|
+
console.timeEnd('JIT TOTAL')
|
|
40
|
+
console.log('\n')
|
|
41
|
+
return root
|
|
42
|
+
},
|
|
43
|
+
].filter(Boolean),
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
module.exports.postcss = true
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# tailwindcss/nesting
|
|
2
|
+
|
|
3
|
+
This is a PostCSS plugin that wraps [postcss-nested](https://github.com/postcss/postcss-nested) or [postcss-nesting](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting) and acts as a compatibility layer to make sure your nesting plugin of choice properly understands Tailwind's custom syntax like `@apply` and `@screen`.
|
|
4
|
+
|
|
5
|
+
Add it to your PostCSS configuration, somewhere before Tailwind itself:
|
|
6
|
+
|
|
7
|
+
```js
|
|
8
|
+
// postcss.config.js
|
|
9
|
+
module.exports = {
|
|
10
|
+
plugins: [
|
|
11
|
+
require('postcss-import'),
|
|
12
|
+
require('tailwindcss/nesting'),
|
|
13
|
+
require('tailwindcss'),
|
|
14
|
+
require('autoprefixer'),
|
|
15
|
+
]
|
|
16
|
+
}
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
By default, it uses the [postcss-nested](https://github.com/postcss/postcss-nested) plugin under the hood, which uses a Sass-like syntax and is the plugin that powers nesting support in the [Tailwind CSS plugin API](https://tailwindcss.com/docs/plugins#css-in-js-syntax).
|
|
20
|
+
|
|
21
|
+
If you'd rather use [postcss-nesting](https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-nesting) (which is based on the work-in-progress [CSS Nesting](https://drafts.csswg.org/css-nesting-1/) specification), first install the plugin alongside:
|
|
22
|
+
|
|
23
|
+
```shell
|
|
24
|
+
npm install postcss-nesting
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
Then pass the plugin itself as an argument to `tailwindcss/nesting` in your PostCSS configuration:
|
|
28
|
+
|
|
29
|
+
```js
|
|
30
|
+
// postcss.config.js
|
|
31
|
+
module.exports = {
|
|
32
|
+
plugins: [
|
|
33
|
+
require('postcss-import'),
|
|
34
|
+
require('tailwindcss/nesting')(require('postcss-nesting')),
|
|
35
|
+
require('tailwindcss'),
|
|
36
|
+
require('autoprefixer'),
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
This can also be helpful if for whatever reason you need to use a very specific version of `postcss-nested` and want to override the version we bundle with `tailwindcss/nesting` itself.
|
|
42
|
+
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import postcss from 'postcss'
|
|
2
|
+
import postcssNested from 'postcss-nested'
|
|
3
|
+
|
|
4
|
+
export function nesting(opts = postcssNested) {
|
|
5
|
+
return (root, result) => {
|
|
6
|
+
root.walkAtRules('screen', (rule) => {
|
|
7
|
+
rule.name = 'media'
|
|
8
|
+
rule.params = `screen(${rule.params})`
|
|
9
|
+
})
|
|
10
|
+
|
|
11
|
+
root.walkAtRules('apply', (rule) => {
|
|
12
|
+
rule.before(postcss.decl({ prop: '__apply', value: rule.params, source: rule.source }))
|
|
13
|
+
rule.remove()
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
let plugin = (() => {
|
|
17
|
+
if (
|
|
18
|
+
typeof opts === 'function' ||
|
|
19
|
+
(typeof opts === 'object' && opts?.hasOwnProperty?.('postcssPlugin'))
|
|
20
|
+
) {
|
|
21
|
+
return opts
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (typeof opts === 'string') {
|
|
25
|
+
return require(opts)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if (Object.keys(opts).length <= 0) {
|
|
29
|
+
return postcssNested
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
throw new Error('tailwindcss/nesting should be loaded with a nesting plugin.')
|
|
33
|
+
})()
|
|
34
|
+
|
|
35
|
+
postcss([plugin]).process(root, result.opts).sync()
|
|
36
|
+
|
|
37
|
+
root.walkDecls('__apply', (decl) => {
|
|
38
|
+
decl.before(postcss.atRule({ name: 'apply', params: decl.value, source: decl.source }))
|
|
39
|
+
decl.remove()
|
|
40
|
+
})
|
|
41
|
+
|
|
42
|
+
/**
|
|
43
|
+
* Use a private PostCSS API to remove the "clean" flag from the entire AST.
|
|
44
|
+
* This is done because running process() on the AST will set the "clean"
|
|
45
|
+
* flag on all nodes, which we don't want.
|
|
46
|
+
*
|
|
47
|
+
* This causes downstream plugins using the visitor API to be skipped.
|
|
48
|
+
*
|
|
49
|
+
* This is guarded because the PostCSS API is not public
|
|
50
|
+
* and may change in future versions of PostCSS.
|
|
51
|
+
*
|
|
52
|
+
* See https://github.com/postcss/postcss/issues/1712 for more details
|
|
53
|
+
*
|
|
54
|
+
* @param {import('postcss').Node} node
|
|
55
|
+
*/
|
|
56
|
+
function markDirty(node) {
|
|
57
|
+
if (!('markDirty' in node)) {
|
|
58
|
+
return
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Traverse the tree down to the leaf nodes
|
|
62
|
+
if (node.nodes) {
|
|
63
|
+
node.nodes.forEach((n) => markDirty(n))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
// If it's a leaf node mark it as dirty
|
|
67
|
+
// We do this here because marking a node as dirty
|
|
68
|
+
// will walk up the tree and mark all parents as dirty
|
|
69
|
+
// resulting in a lot of unnecessary work if we did this
|
|
70
|
+
// for every single node
|
|
71
|
+
if (!node.nodes) {
|
|
72
|
+
node.markDirty()
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
markDirty(root)
|
|
77
|
+
|
|
78
|
+
return root
|
|
79
|
+
}
|
|
80
|
+
}
|
|
@@ -6,14 +6,18 @@ import substituteScreenAtRules from './lib/substituteScreenAtRules'
|
|
|
6
6
|
import resolveDefaultsAtRules from './lib/resolveDefaultsAtRules'
|
|
7
7
|
import collapseAdjacentRules from './lib/collapseAdjacentRules'
|
|
8
8
|
import collapseDuplicateDeclarations from './lib/collapseDuplicateDeclarations'
|
|
9
|
-
import
|
|
9
|
+
import partitionApplyAtRules from './lib/partitionApplyAtRules'
|
|
10
10
|
import { createContext } from './lib/setupContextUtils'
|
|
11
11
|
import { issueFlagNotices } from './featureFlags'
|
|
12
12
|
|
|
13
13
|
export default function processTailwindFeatures(setupContext) {
|
|
14
|
-
return function (root, result) {
|
|
14
|
+
return async function (root, result) {
|
|
15
15
|
let { tailwindDirectives, applyDirectives } = normalizeTailwindDirectives(root)
|
|
16
16
|
|
|
17
|
+
// Partition apply rules that are found in the css
|
|
18
|
+
// itself.
|
|
19
|
+
partitionApplyAtRules()(root, result)
|
|
20
|
+
|
|
17
21
|
let context = setupContext({
|
|
18
22
|
tailwindDirectives,
|
|
19
23
|
applyDirectives,
|
|
@@ -37,8 +41,11 @@ export default function processTailwindFeatures(setupContext) {
|
|
|
37
41
|
|
|
38
42
|
issueFlagNotices(context.tailwindConfig)
|
|
39
43
|
|
|
40
|
-
|
|
41
|
-
|
|
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)
|
|
42
49
|
expandApplyAtRules(context)(root, result)
|
|
43
50
|
evaluateTailwindFunctions(context)(root, result)
|
|
44
51
|
substituteScreenAtRules(context)(root, result)
|
package/src/public/colors.js
CHANGED
|
@@ -24,6 +24,7 @@ export default {
|
|
|
24
24
|
700: '#334155',
|
|
25
25
|
800: '#1e293b',
|
|
26
26
|
900: '#0f172a',
|
|
27
|
+
950: '#020617',
|
|
27
28
|
},
|
|
28
29
|
gray: {
|
|
29
30
|
50: '#f9fafb',
|
|
@@ -36,6 +37,7 @@ export default {
|
|
|
36
37
|
700: '#374151',
|
|
37
38
|
800: '#1f2937',
|
|
38
39
|
900: '#111827',
|
|
40
|
+
950: '#030712',
|
|
39
41
|
},
|
|
40
42
|
zinc: {
|
|
41
43
|
50: '#fafafa',
|
|
@@ -48,6 +50,7 @@ export default {
|
|
|
48
50
|
700: '#3f3f46',
|
|
49
51
|
800: '#27272a',
|
|
50
52
|
900: '#18181b',
|
|
53
|
+
950: '#09090b',
|
|
51
54
|
},
|
|
52
55
|
neutral: {
|
|
53
56
|
50: '#fafafa',
|
|
@@ -60,6 +63,7 @@ export default {
|
|
|
60
63
|
700: '#404040',
|
|
61
64
|
800: '#262626',
|
|
62
65
|
900: '#171717',
|
|
66
|
+
950: '#0a0a0a',
|
|
63
67
|
},
|
|
64
68
|
stone: {
|
|
65
69
|
50: '#fafaf9',
|
|
@@ -72,6 +76,7 @@ export default {
|
|
|
72
76
|
700: '#44403c',
|
|
73
77
|
800: '#292524',
|
|
74
78
|
900: '#1c1917',
|
|
79
|
+
950: '#0c0a09',
|
|
75
80
|
},
|
|
76
81
|
red: {
|
|
77
82
|
50: '#fef2f2',
|
|
@@ -84,6 +89,7 @@ export default {
|
|
|
84
89
|
700: '#b91c1c',
|
|
85
90
|
800: '#991b1b',
|
|
86
91
|
900: '#7f1d1d',
|
|
92
|
+
950: '#450a0a',
|
|
87
93
|
},
|
|
88
94
|
orange: {
|
|
89
95
|
50: '#fff7ed',
|
|
@@ -96,6 +102,7 @@ export default {
|
|
|
96
102
|
700: '#c2410c',
|
|
97
103
|
800: '#9a3412',
|
|
98
104
|
900: '#7c2d12',
|
|
105
|
+
950: '#431407',
|
|
99
106
|
},
|
|
100
107
|
amber: {
|
|
101
108
|
50: '#fffbeb',
|
|
@@ -108,6 +115,7 @@ export default {
|
|
|
108
115
|
700: '#b45309',
|
|
109
116
|
800: '#92400e',
|
|
110
117
|
900: '#78350f',
|
|
118
|
+
950: '#451a03',
|
|
111
119
|
},
|
|
112
120
|
yellow: {
|
|
113
121
|
50: '#fefce8',
|
|
@@ -120,6 +128,7 @@ export default {
|
|
|
120
128
|
700: '#a16207',
|
|
121
129
|
800: '#854d0e',
|
|
122
130
|
900: '#713f12',
|
|
131
|
+
950: '#422006',
|
|
123
132
|
},
|
|
124
133
|
lime: {
|
|
125
134
|
50: '#f7fee7',
|
|
@@ -132,6 +141,7 @@ export default {
|
|
|
132
141
|
700: '#4d7c0f',
|
|
133
142
|
800: '#3f6212',
|
|
134
143
|
900: '#365314',
|
|
144
|
+
950: '#1a2e05',
|
|
135
145
|
},
|
|
136
146
|
green: {
|
|
137
147
|
50: '#f0fdf4',
|
|
@@ -144,6 +154,7 @@ export default {
|
|
|
144
154
|
700: '#15803d',
|
|
145
155
|
800: '#166534',
|
|
146
156
|
900: '#14532d',
|
|
157
|
+
950: '#052e16',
|
|
147
158
|
},
|
|
148
159
|
emerald: {
|
|
149
160
|
50: '#ecfdf5',
|
|
@@ -156,6 +167,7 @@ export default {
|
|
|
156
167
|
700: '#047857',
|
|
157
168
|
800: '#065f46',
|
|
158
169
|
900: '#064e3b',
|
|
170
|
+
950: '#022c22',
|
|
159
171
|
},
|
|
160
172
|
teal: {
|
|
161
173
|
50: '#f0fdfa',
|
|
@@ -168,6 +180,7 @@ export default {
|
|
|
168
180
|
700: '#0f766e',
|
|
169
181
|
800: '#115e59',
|
|
170
182
|
900: '#134e4a',
|
|
183
|
+
950: '#042f2e',
|
|
171
184
|
},
|
|
172
185
|
cyan: {
|
|
173
186
|
50: '#ecfeff',
|
|
@@ -180,6 +193,7 @@ export default {
|
|
|
180
193
|
700: '#0e7490',
|
|
181
194
|
800: '#155e75',
|
|
182
195
|
900: '#164e63',
|
|
196
|
+
950: '#083344',
|
|
183
197
|
},
|
|
184
198
|
sky: {
|
|
185
199
|
50: '#f0f9ff',
|
|
@@ -192,6 +206,7 @@ export default {
|
|
|
192
206
|
700: '#0369a1',
|
|
193
207
|
800: '#075985',
|
|
194
208
|
900: '#0c4a6e',
|
|
209
|
+
950: '#082f49',
|
|
195
210
|
},
|
|
196
211
|
blue: {
|
|
197
212
|
50: '#eff6ff',
|
|
@@ -204,6 +219,7 @@ export default {
|
|
|
204
219
|
700: '#1d4ed8',
|
|
205
220
|
800: '#1e40af',
|
|
206
221
|
900: '#1e3a8a',
|
|
222
|
+
950: '#172554',
|
|
207
223
|
},
|
|
208
224
|
indigo: {
|
|
209
225
|
50: '#eef2ff',
|
|
@@ -216,6 +232,7 @@ export default {
|
|
|
216
232
|
700: '#4338ca',
|
|
217
233
|
800: '#3730a3',
|
|
218
234
|
900: '#312e81',
|
|
235
|
+
950: '#1e1b4b',
|
|
219
236
|
},
|
|
220
237
|
violet: {
|
|
221
238
|
50: '#f5f3ff',
|
|
@@ -228,6 +245,7 @@ export default {
|
|
|
228
245
|
700: '#6d28d9',
|
|
229
246
|
800: '#5b21b6',
|
|
230
247
|
900: '#4c1d95',
|
|
248
|
+
950: '#2e1065',
|
|
231
249
|
},
|
|
232
250
|
purple: {
|
|
233
251
|
50: '#faf5ff',
|
|
@@ -240,6 +258,7 @@ export default {
|
|
|
240
258
|
700: '#7e22ce',
|
|
241
259
|
800: '#6b21a8',
|
|
242
260
|
900: '#581c87',
|
|
261
|
+
950: '#3b0764',
|
|
243
262
|
},
|
|
244
263
|
fuchsia: {
|
|
245
264
|
50: '#fdf4ff',
|
|
@@ -252,6 +271,7 @@ export default {
|
|
|
252
271
|
700: '#a21caf',
|
|
253
272
|
800: '#86198f',
|
|
254
273
|
900: '#701a75',
|
|
274
|
+
950: '#4a044e',
|
|
255
275
|
},
|
|
256
276
|
pink: {
|
|
257
277
|
50: '#fdf2f8',
|
|
@@ -264,6 +284,7 @@ export default {
|
|
|
264
284
|
700: '#be185d',
|
|
265
285
|
800: '#9d174d',
|
|
266
286
|
900: '#831843',
|
|
287
|
+
950: '#500724',
|
|
267
288
|
},
|
|
268
289
|
rose: {
|
|
269
290
|
50: '#fff1f2',
|
|
@@ -276,6 +297,7 @@ export default {
|
|
|
276
297
|
700: '#be123c',
|
|
277
298
|
800: '#9f1239',
|
|
278
299
|
900: '#881337',
|
|
300
|
+
950: '#4c0519',
|
|
279
301
|
},
|
|
280
302
|
get lightBlue() {
|
|
281
303
|
warn({ version: 'v2.2', from: 'lightBlue', to: 'sky' })
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import parser from 'postcss-selector-parser'
|
|
2
|
+
import { movePseudos } from './pseudoElements'
|
|
3
|
+
|
|
4
|
+
export function applyImportantSelector(selector, important) {
|
|
5
|
+
let sel = parser().astSync(selector)
|
|
6
|
+
|
|
7
|
+
sel.each((sel) => {
|
|
8
|
+
// Wrap with :is if it's not already wrapped
|
|
9
|
+
let isWrapped =
|
|
10
|
+
sel.nodes[0].type === 'pseudo' &&
|
|
11
|
+
sel.nodes[0].value === ':is' &&
|
|
12
|
+
sel.nodes.every((node) => node.type !== 'combinator')
|
|
13
|
+
|
|
14
|
+
if (!isWrapped) {
|
|
15
|
+
sel.nodes = [
|
|
16
|
+
parser.pseudo({
|
|
17
|
+
value: ':is',
|
|
18
|
+
nodes: [sel.clone()],
|
|
19
|
+
}),
|
|
20
|
+
]
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
movePseudos(sel)
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
return `${important} ${sel.toString()}`
|
|
27
|
+
}
|
|
@@ -2,8 +2,8 @@ export default function buildMediaQuery(screens) {
|
|
|
2
2
|
screens = Array.isArray(screens) ? screens : [screens]
|
|
3
3
|
|
|
4
4
|
return screens
|
|
5
|
-
.map((screen) =>
|
|
6
|
-
screen.values.map((screen) => {
|
|
5
|
+
.map((screen) => {
|
|
6
|
+
let values = screen.values.map((screen) => {
|
|
7
7
|
if (screen.raw !== undefined) {
|
|
8
8
|
return screen.raw
|
|
9
9
|
}
|
|
@@ -15,6 +15,8 @@ export default function buildMediaQuery(screens) {
|
|
|
15
15
|
.filter(Boolean)
|
|
16
16
|
.join(' and ')
|
|
17
17
|
})
|
|
18
|
-
|
|
18
|
+
|
|
19
|
+
return screen.not ? `not all and ${values}` : values
|
|
20
|
+
})
|
|
19
21
|
.join(', ')
|
|
20
22
|
}
|