tailwindcss 0.0.0-insiders.f4635e0 → 0.0.0-insiders.f4a2ccd
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 +15 -7
- package/colors.d.ts +3 -0
- package/colors.js +2 -304
- package/defaultConfig.d.ts +3 -0
- package/defaultConfig.js +2 -4
- package/defaultTheme.d.ts +4 -0
- package/defaultTheme.js +2 -4
- package/lib/cli/build/deps.js +54 -0
- package/lib/cli/build/index.js +52 -0
- package/lib/cli/build/plugin.js +376 -0
- package/lib/cli/build/utils.js +78 -0
- package/lib/cli/build/watching.js +180 -0
- package/lib/cli/help/index.js +71 -0
- package/lib/cli/index.js +230 -0
- package/lib/cli/init/index.js +61 -0
- package/lib/cli-peer-dependencies.js +22 -14
- package/lib/cli.js +4 -762
- package/lib/corePluginList.js +182 -5
- package/lib/corePlugins.js +4109 -2952
- package/lib/css/preflight.css +24 -9
- package/lib/featureFlags.js +68 -50
- package/lib/index.js +5 -30
- package/lib/lib/cacheInvalidation.js +90 -0
- package/lib/lib/collapseAdjacentRules.js +52 -36
- package/lib/lib/collapseDuplicateDeclarations.js +83 -0
- package/lib/lib/content.js +177 -0
- package/lib/lib/defaultExtractor.js +241 -0
- package/lib/lib/detectNesting.js +39 -17
- package/lib/lib/evaluateTailwindFunctions.js +203 -161
- package/lib/lib/expandApplyAtRules.js +503 -221
- package/lib/lib/expandTailwindAtRules.js +255 -243
- package/lib/lib/findAtConfigPath.js +44 -0
- package/lib/lib/generateRules.js +831 -317
- package/lib/lib/getModuleDependencies.js +93 -49
- package/lib/lib/load-config.js +36 -0
- package/lib/lib/normalizeTailwindDirectives.js +79 -60
- package/lib/lib/offsets.js +304 -0
- package/lib/lib/partitionApplyAtRules.js +56 -0
- package/lib/lib/regex.js +60 -0
- package/lib/lib/remap-bitfield.js +87 -0
- package/lib/lib/resolveDefaultsAtRules.js +150 -94
- package/lib/lib/setupContextUtils.js +1197 -685
- package/lib/lib/setupTrackingContext.js +150 -177
- package/lib/lib/sharedState.js +70 -21
- package/lib/lib/substituteScreenAtRules.js +26 -28
- package/lib/oxide/cli/build/deps.js +81 -0
- package/lib/oxide/cli/build/index.js +51 -0
- package/lib/oxide/cli/build/plugin.js +373 -0
- package/lib/oxide/cli/build/utils.js +77 -0
- package/lib/oxide/cli/build/watching.js +177 -0
- package/lib/oxide/cli/help/index.js +70 -0
- package/lib/oxide/cli/index.js +214 -0
- package/lib/oxide/cli/init/index.js +50 -0
- package/lib/oxide/cli.js +5 -0
- package/lib/oxide/postcss-plugin.js +2 -0
- package/lib/plugin.js +98 -0
- package/{nesting → lib/postcss-plugins/nesting}/README.md +2 -2
- package/lib/postcss-plugins/nesting/index.js +19 -0
- package/lib/postcss-plugins/nesting/plugin.js +87 -0
- package/lib/processTailwindFeatures.js +58 -56
- package/lib/public/colors.js +353 -0
- package/lib/public/create-plugin.js +15 -0
- package/lib/public/default-config.js +16 -0
- package/lib/public/default-theme.js +16 -0
- package/lib/public/load-config.js +10 -0
- package/lib/public/resolve-config.js +22 -0
- package/lib/util/applyImportantSelector.js +22 -0
- package/lib/util/bigSign.js +7 -6
- package/lib/util/buildMediaQuery.js +21 -32
- package/lib/util/cloneDeep.js +16 -14
- package/lib/util/cloneNodes.js +29 -15
- package/lib/util/color.js +104 -66
- package/lib/util/configurePlugins.js +17 -15
- package/lib/util/createPlugin.js +23 -26
- package/lib/util/createUtilityPlugin.js +46 -46
- package/lib/util/dataTypes.js +266 -0
- package/lib/util/defaults.js +20 -15
- package/lib/util/escapeClassName.js +18 -17
- package/lib/util/escapeCommas.js +7 -6
- package/lib/util/flattenColorPalette.js +13 -12
- package/lib/util/formatVariantSelector.js +341 -0
- package/lib/util/getAllConfigs.js +44 -18
- package/lib/util/hashConfig.js +15 -12
- package/lib/util/isKeyframeRule.js +7 -6
- package/lib/util/isPlainObject.js +11 -11
- package/lib/util/isSyntacticallyValidPropertyValue.js +72 -0
- package/lib/util/log.js +52 -33
- package/lib/util/nameClass.js +35 -29
- package/lib/util/negateValue.js +31 -17
- package/lib/util/normalizeConfig.js +294 -0
- package/lib/util/normalizeScreens.js +170 -0
- package/lib/util/parseAnimationValue.js +85 -54
- package/lib/util/parseBoxShadowValue.js +84 -0
- package/lib/util/parseDependency.js +41 -70
- package/lib/util/parseGlob.js +34 -0
- package/lib/util/parseObjectStyles.js +30 -24
- package/lib/util/pluginUtils.js +234 -288
- package/lib/util/prefixSelector.js +33 -19
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +221 -256
- package/lib/util/resolveConfigPath.js +55 -48
- package/lib/util/responsive.js +18 -14
- package/lib/util/splitAtTopLevelOnly.js +49 -0
- package/lib/util/tap.js +8 -7
- package/lib/util/toColorValue.js +7 -6
- package/lib/util/toPath.js +27 -8
- package/lib/util/transformThemeValue.js +67 -28
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/validateFormalSyntax.js +24 -0
- package/lib/util/withAlphaVariable.js +67 -57
- package/loadConfig.d.ts +4 -0
- package/loadConfig.js +2 -0
- package/nesting/index.js +2 -12
- package/package.json +69 -66
- package/peers/index.js +76328 -84169
- package/plugin.d.ts +11 -0
- package/plugin.js +1 -2
- package/resolveConfig.d.ts +12 -0
- package/resolveConfig.js +2 -7
- package/scripts/create-plugin-list.js +2 -2
- package/scripts/generate-types.js +105 -0
- package/scripts/release-channel.js +18 -0
- package/scripts/release-notes.js +21 -0
- package/scripts/swap-engines.js +40 -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 +444 -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 +4 -756
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +2526 -1956
- package/src/css/preflight.css +24 -9
- package/src/featureFlags.js +33 -10
- package/src/index.js +4 -33
- package/src/lib/cacheInvalidation.js +52 -0
- package/src/lib/collapseAdjacentRules.js +21 -2
- package/src/lib/collapseDuplicateDeclarations.js +93 -0
- package/src/lib/content.js +208 -0
- package/src/lib/defaultExtractor.js +217 -0
- package/src/lib/detectNesting.js +30 -3
- package/src/lib/evaluateTailwindFunctions.js +84 -10
- package/src/lib/expandApplyAtRules.js +509 -153
- package/src/lib/expandTailwindAtRules.js +125 -104
- package/src/lib/findAtConfigPath.js +48 -0
- package/src/lib/generateRules.js +678 -70
- package/src/lib/getModuleDependencies.js +70 -30
- package/src/lib/load-config.ts +27 -0
- package/src/lib/normalizeTailwindDirectives.js +10 -3
- package/src/lib/offsets.js +373 -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 +105 -47
- package/src/lib/setupContextUtils.js +848 -247
- package/src/lib/setupTrackingContext.js +53 -64
- package/src/lib/sharedState.js +60 -6
- package/src/lib/substituteScreenAtRules.js +6 -3
- package/src/oxide/cli/build/deps.ts +91 -0
- package/src/oxide/cli/build/index.ts +47 -0
- package/src/oxide/cli/build/plugin.ts +442 -0
- package/src/oxide/cli/build/utils.ts +74 -0
- package/src/oxide/cli/build/watching.ts +225 -0
- package/src/oxide/cli/help/index.ts +69 -0
- package/src/oxide/cli/index.ts +204 -0
- package/src/oxide/cli/init/index.ts +59 -0
- package/src/oxide/cli.ts +1 -0
- package/src/oxide/postcss-plugin.ts +1 -0
- package/src/plugin.js +107 -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 +18 -3
- package/src/public/colors.js +322 -0
- package/src/public/create-plugin.js +2 -0
- package/src/public/default-config.js +4 -0
- package/src/public/default-theme.js +4 -0
- package/src/public/load-config.js +2 -0
- package/src/public/resolve-config.js +7 -0
- package/src/util/applyImportantSelector.js +19 -0
- package/src/util/buildMediaQuery.js +14 -16
- package/src/util/cloneNodes.js +19 -2
- package/src/util/color.js +43 -11
- package/src/util/createUtilityPlugin.js +2 -11
- package/src/util/dataTypes.js +281 -0
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +412 -0
- package/src/util/getAllConfigs.js +21 -2
- package/src/util/isSyntacticallyValidPropertyValue.js +61 -0
- package/src/util/log.js +23 -22
- package/src/util/nameClass.js +6 -2
- package/src/util/negateValue.js +15 -5
- package/src/util/normalizeConfig.js +318 -0
- package/src/util/normalizeScreens.js +140 -0
- package/src/util/parseAnimationValue.js +7 -1
- package/src/util/parseBoxShadowValue.js +72 -0
- package/src/util/parseDependency.js +37 -38
- package/src/util/parseGlob.js +24 -0
- package/src/util/pluginUtils.js +219 -219
- package/src/util/prefixSelector.js +30 -13
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +86 -91
- package/src/util/resolveConfigPath.js +12 -1
- package/src/util/splitAtTopLevelOnly.js +52 -0
- package/src/util/toPath.js +23 -1
- package/src/util/transformThemeValue.js +33 -8
- package/src/util/validateConfig.js +13 -0
- package/src/util/validateFormalSyntax.js +34 -0
- package/src/util/withAlphaVariable.js +14 -9
- package/stubs/.gitignore +1 -0
- package/stubs/.prettierrc.json +6 -0
- package/stubs/{defaultConfig.stub.js → config.full.js} +332 -249
- package/stubs/{simpleConfig.stub.js → config.simple.js} +0 -1
- 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 +373 -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 +347 -0
- package/types/index.d.ts +7 -0
- package/CHANGELOG.md +0 -1742
- package/lib/constants.js +0 -37
- package/lib/lib/setupWatchingContext.js +0 -331
- 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/setupWatchingContext.js +0 -307
- /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
|
|
3
|
+
import fs from 'fs'
|
|
5
4
|
import LRU from 'quick-lru'
|
|
6
|
-
import normalizePath from 'normalize-path'
|
|
7
5
|
|
|
8
6
|
import hash from '../util/hashConfig'
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
import resolveConfig from '../../resolveConfig'
|
|
12
|
-
|
|
7
|
+
import resolveConfig from '../public/resolve-config'
|
|
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(path.resolve(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,7 +56,7 @@ 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]
|
|
@@ -73,39 +67,9 @@ function getTailwindConfig(configOrPath) {
|
|
|
73
67
|
configOrPath.config === undefined ? configOrPath : configOrPath.config
|
|
74
68
|
)
|
|
75
69
|
|
|
76
|
-
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function resolvedChangedContent(context, candidateFiles, fileModifiedMap) {
|
|
80
|
-
let changedContent = context.tailwindConfig.content.content
|
|
81
|
-
.filter((item) => typeof item.raw === 'string')
|
|
82
|
-
.concat(context.tailwindConfig.content.safelist)
|
|
83
|
-
.concat(context.safelist())
|
|
84
|
-
.map(({ raw, extension }) => ({ content: raw, extension }))
|
|
85
|
-
|
|
86
|
-
for (let changedFile of resolveChangedFiles(candidateFiles, fileModifiedMap)) {
|
|
87
|
-
let content = fs.readFileSync(changedFile, 'utf8')
|
|
88
|
-
let extension = path.extname(changedFile).slice(1)
|
|
89
|
-
changedContent.push({ content, extension })
|
|
90
|
-
}
|
|
91
|
-
return changedContent
|
|
92
|
-
}
|
|
70
|
+
newConfig = validateConfig(newConfig)
|
|
93
71
|
|
|
94
|
-
|
|
95
|
-
let changedFiles = new Set()
|
|
96
|
-
env.DEBUG && console.time('Finding changed files')
|
|
97
|
-
let files = fastGlob.sync(candidateFiles)
|
|
98
|
-
for (let file of files) {
|
|
99
|
-
let prevModified = fileModifiedMap.has(file) ? fileModifiedMap.get(file) : -Infinity
|
|
100
|
-
let modified = fs.statSync(file).mtimeMs
|
|
101
|
-
|
|
102
|
-
if (modified > prevModified) {
|
|
103
|
-
changedFiles.add(file)
|
|
104
|
-
fileModifiedMap.set(file, modified)
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
env.DEBUG && console.timeEnd('Finding changed files')
|
|
108
|
-
return changedFiles
|
|
72
|
+
return [newConfig, null, hash(newConfig), []]
|
|
109
73
|
}
|
|
110
74
|
|
|
111
75
|
// DISABLE_TOUCH = TRUE
|
|
@@ -121,11 +85,12 @@ export default function setupTrackingContext(configOrPath) {
|
|
|
121
85
|
|
|
122
86
|
let contextDependencies = new Set(configDependencies)
|
|
123
87
|
|
|
124
|
-
// If there are no @tailwind rules, we don't consider this CSS
|
|
125
|
-
// to be dependencies of the context. Can reuse
|
|
126
|
-
// We may want to think about `@layer`
|
|
127
|
-
//
|
|
128
|
-
// in
|
|
88
|
+
// If there are no @tailwind or @apply rules, we don't consider this CSS
|
|
89
|
+
// file or its dependencies to be dependencies of the context. Can reuse
|
|
90
|
+
// the context even if they change. We may want to think about `@layer`
|
|
91
|
+
// being part of this trigger too, but it's tough because it's impossible
|
|
92
|
+
// for a layer in one file to end up in the actual @tailwind rule in
|
|
93
|
+
// another file since independent sources are effectively isolated.
|
|
129
94
|
if (tailwindDirectives.size > 0) {
|
|
130
95
|
// Add current css file as a context dependencies.
|
|
131
96
|
contextDependencies.add(result.opts.from)
|
|
@@ -138,8 +103,7 @@ export default function setupTrackingContext(configOrPath) {
|
|
|
138
103
|
}
|
|
139
104
|
}
|
|
140
105
|
|
|
141
|
-
let [context] = getContext(
|
|
142
|
-
tailwindDirectives,
|
|
106
|
+
let [context, , mTimesToCommit] = getContext(
|
|
143
107
|
root,
|
|
144
108
|
result,
|
|
145
109
|
tailwindConfig,
|
|
@@ -148,27 +112,45 @@ export default function setupTrackingContext(configOrPath) {
|
|
|
148
112
|
contextDependencies
|
|
149
113
|
)
|
|
150
114
|
|
|
115
|
+
let fileModifiedMap = getFileModifiedMap(context)
|
|
116
|
+
|
|
151
117
|
let candidateFiles = getCandidateFiles(context, tailwindConfig)
|
|
152
118
|
|
|
153
|
-
// If there are no @tailwind rules, we don't consider this CSS file or it's
|
|
154
|
-
// to be dependencies of the context. Can reuse the context even if they change.
|
|
119
|
+
// If there are no @tailwind or @apply rules, we don't consider this CSS file or it's
|
|
120
|
+
// dependencies to be dependencies of the context. Can reuse the context even if they change.
|
|
155
121
|
// We may want to think about `@layer` being part of this trigger too, but it's tough
|
|
156
122
|
// because it's impossible for a layer in one file to end up in the actual @tailwind rule
|
|
157
123
|
// in another file since independent sources are effectively isolated.
|
|
158
124
|
if (tailwindDirectives.size > 0) {
|
|
159
|
-
let fileModifiedMap = getFileModifiedMap(context)
|
|
160
|
-
|
|
161
125
|
// Add template paths as postcss dependencies.
|
|
162
|
-
for (let
|
|
163
|
-
|
|
126
|
+
for (let contentPath of candidateFiles) {
|
|
127
|
+
for (let dependency of parseDependency(contentPath)) {
|
|
128
|
+
registerDependency(dependency)
|
|
129
|
+
}
|
|
164
130
|
}
|
|
165
131
|
|
|
166
|
-
|
|
132
|
+
let [changedContent, contentMTimesToCommit] = resolvedChangedContent(
|
|
167
133
|
context,
|
|
168
134
|
candidateFiles,
|
|
169
135
|
fileModifiedMap
|
|
170
|
-
)
|
|
171
|
-
|
|
136
|
+
)
|
|
137
|
+
|
|
138
|
+
for (let content of changedContent) {
|
|
139
|
+
context.changedContent.push(content)
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
// Add the mtimes of the content files to the commit list
|
|
143
|
+
// We can overwrite the existing values because unconditionally
|
|
144
|
+
// This is because:
|
|
145
|
+
// 1. Most of the files here won't be in the map yet
|
|
146
|
+
// 2. If they are that means it's a context dependency
|
|
147
|
+
// and we're reading this after the context. This means
|
|
148
|
+
// that the mtime we just read is strictly >= the context
|
|
149
|
+
// mtime. Unless the user / os is doing something weird
|
|
150
|
+
// in which the mtime would be going backwards. If that
|
|
151
|
+
// happens there's already going to be problems.
|
|
152
|
+
for (let [path, mtime] of contentMTimesToCommit.entries()) {
|
|
153
|
+
mTimesToCommit.set(path, mtime)
|
|
172
154
|
}
|
|
173
155
|
}
|
|
174
156
|
|
|
@@ -176,6 +158,13 @@ export default function setupTrackingContext(configOrPath) {
|
|
|
176
158
|
registerDependency({ type: 'dependency', file })
|
|
177
159
|
}
|
|
178
160
|
|
|
161
|
+
// "commit" the new modified time for all context deps
|
|
162
|
+
// We do this here because we want content tracking to
|
|
163
|
+
// read the "old" mtime even when it's a context dependency.
|
|
164
|
+
for (let [path, mtime] of mTimesToCommit.entries()) {
|
|
165
|
+
fileModifiedMap.set(path, mtime)
|
|
166
|
+
}
|
|
167
|
+
|
|
179
168
|
return context
|
|
180
169
|
}
|
|
181
170
|
}
|
package/src/lib/sharedState.js
CHANGED
|
@@ -1,13 +1,67 @@
|
|
|
1
|
-
import
|
|
1
|
+
import pkg from '../../package.json'
|
|
2
|
+
let OXIDE_DEFAULT_ENABLED = pkg.tailwindcss.engine === 'oxide'
|
|
2
3
|
|
|
3
4
|
export const env = {
|
|
4
|
-
TAILWIND_MODE: process.env.TAILWIND_MODE,
|
|
5
5
|
NODE_ENV: process.env.NODE_ENV,
|
|
6
|
-
DEBUG: process.env.DEBUG
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
DEBUG: resolveDebug(process.env.DEBUG),
|
|
7
|
+
ENGINE: pkg.tailwindcss.engine,
|
|
8
|
+
OXIDE: resolveBoolean(process.env.OXIDE, OXIDE_DEFAULT_ENABLED),
|
|
9
9
|
}
|
|
10
10
|
export const contextMap = new Map()
|
|
11
11
|
export const configContextMap = new Map()
|
|
12
12
|
export const contextSourcesMap = new Map()
|
|
13
|
-
export const
|
|
13
|
+
export const sourceHashMap = new Map()
|
|
14
|
+
export const NOT_ON_DEMAND = new String('*')
|
|
15
|
+
|
|
16
|
+
export const NONE = Symbol('__NONE__')
|
|
17
|
+
|
|
18
|
+
function resolveBoolean(value, defaultValue) {
|
|
19
|
+
if (value === undefined) {
|
|
20
|
+
return defaultValue
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
if (value === '0' || value === 'false') {
|
|
24
|
+
return false
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
return true
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function resolveDebug(debug) {
|
|
31
|
+
if (debug === undefined) {
|
|
32
|
+
return false
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
// Environment variables are strings, so convert to boolean
|
|
36
|
+
if (debug === 'true' || debug === '1') {
|
|
37
|
+
return true
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
if (debug === 'false' || debug === '0') {
|
|
41
|
+
return false
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// Keep the debug convention into account:
|
|
45
|
+
// DEBUG=* -> This enables all debug modes
|
|
46
|
+
// DEBUG=projectA,projectB,projectC -> This enables debug for projectA, projectB and projectC
|
|
47
|
+
// DEBUG=projectA:* -> This enables all debug modes for projectA (if you have sub-types)
|
|
48
|
+
// DEBUG=projectA,-projectB -> This enables debug for projectA and explicitly disables it for projectB
|
|
49
|
+
|
|
50
|
+
if (debug === '*') {
|
|
51
|
+
return true
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
let debuggers = debug.split(',').map((d) => d.split(':')[0])
|
|
55
|
+
|
|
56
|
+
// Ignoring tailwindcss
|
|
57
|
+
if (debuggers.includes('-tailwindcss')) {
|
|
58
|
+
return false
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
// Including tailwindcss
|
|
62
|
+
if (debuggers.includes('tailwindcss')) {
|
|
63
|
+
return true
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return false
|
|
67
|
+
}
|
|
@@ -1,16 +1,19 @@
|
|
|
1
|
+
import { normalizeScreens } from '../util/normalizeScreens'
|
|
1
2
|
import buildMediaQuery from '../util/buildMediaQuery'
|
|
2
3
|
|
|
3
4
|
export default function ({ tailwindConfig: { theme } }) {
|
|
4
5
|
return function (css) {
|
|
5
6
|
css.walkAtRules('screen', (atRule) => {
|
|
6
|
-
|
|
7
|
+
let screen = atRule.params
|
|
8
|
+
let screens = normalizeScreens(theme.screens)
|
|
9
|
+
let screenDefinition = screens.find(({ name }) => name === screen)
|
|
7
10
|
|
|
8
|
-
if (!
|
|
11
|
+
if (!screenDefinition) {
|
|
9
12
|
throw atRule.error(`No \`${screen}\` screen found.`)
|
|
10
13
|
}
|
|
11
14
|
|
|
12
15
|
atRule.name = 'media'
|
|
13
|
-
atRule.params = buildMediaQuery(
|
|
16
|
+
atRule.params = buildMediaQuery(screenDefinition)
|
|
14
17
|
})
|
|
15
18
|
}
|
|
16
19
|
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import packageJson from '../../../../package.json'
|
|
2
|
+
import browserslist from 'browserslist'
|
|
3
|
+
import { Result } from 'postcss'
|
|
4
|
+
|
|
5
|
+
import {
|
|
6
|
+
// @ts-ignore
|
|
7
|
+
lazyPostcss,
|
|
8
|
+
|
|
9
|
+
// @ts-ignore
|
|
10
|
+
lazyPostcssImport,
|
|
11
|
+
|
|
12
|
+
// @ts-ignore
|
|
13
|
+
lazyCssnano,
|
|
14
|
+
|
|
15
|
+
// @ts-ignore
|
|
16
|
+
} from '../../../../peers/index'
|
|
17
|
+
|
|
18
|
+
export function lazyLightningCss() {
|
|
19
|
+
// TODO: Make this lazy/bundled
|
|
20
|
+
return require('lightningcss')
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let lightningCss
|
|
24
|
+
|
|
25
|
+
function loadLightningCss() {
|
|
26
|
+
if (lightningCss) {
|
|
27
|
+
return lightningCss
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Try to load a local version first
|
|
31
|
+
try {
|
|
32
|
+
return (lightningCss = require('lightningcss'))
|
|
33
|
+
} catch {}
|
|
34
|
+
|
|
35
|
+
return (lightningCss = lazyLightningCss())
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export async function lightningcss(shouldMinify: boolean, result: Result) {
|
|
39
|
+
let css = loadLightningCss()
|
|
40
|
+
|
|
41
|
+
try {
|
|
42
|
+
let transformed = css.transform({
|
|
43
|
+
filename: result.opts.from || 'input.css',
|
|
44
|
+
code: Buffer.from(result.css, 'utf-8'),
|
|
45
|
+
minify: shouldMinify,
|
|
46
|
+
sourceMap: !!result.map,
|
|
47
|
+
inputSourceMap: result.map ? result.map.toString() : undefined,
|
|
48
|
+
targets: css.browserslistToTargets(browserslist(packageJson.browserslist)),
|
|
49
|
+
drafts: {
|
|
50
|
+
nesting: true,
|
|
51
|
+
},
|
|
52
|
+
})
|
|
53
|
+
|
|
54
|
+
return Object.assign(result, {
|
|
55
|
+
css: transformed.code.toString('utf8'),
|
|
56
|
+
map: result.map
|
|
57
|
+
? Object.assign(result.map, {
|
|
58
|
+
toString() {
|
|
59
|
+
return transformed.map.toString()
|
|
60
|
+
},
|
|
61
|
+
})
|
|
62
|
+
: result.map,
|
|
63
|
+
})
|
|
64
|
+
} catch (err) {
|
|
65
|
+
console.error('Unable to use Lightning CSS. Using raw version instead.')
|
|
66
|
+
console.error(err)
|
|
67
|
+
|
|
68
|
+
return result
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
/**
|
|
73
|
+
* @returns {import('postcss')}
|
|
74
|
+
*/
|
|
75
|
+
export function loadPostcss() {
|
|
76
|
+
// Try to load a local `postcss` version first
|
|
77
|
+
try {
|
|
78
|
+
return require('postcss')
|
|
79
|
+
} catch {}
|
|
80
|
+
|
|
81
|
+
return lazyPostcss()
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function loadPostcssImport() {
|
|
85
|
+
// Try to load a local `postcss-import` version first
|
|
86
|
+
try {
|
|
87
|
+
return require('postcss-import')
|
|
88
|
+
} catch {}
|
|
89
|
+
|
|
90
|
+
return lazyPostcssImport()
|
|
91
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import fs from 'fs'
|
|
2
|
+
import path from 'path'
|
|
3
|
+
import { resolveDefaultConfigPath } from '../../../util/resolveConfigPath'
|
|
4
|
+
import { createProcessor } from './plugin'
|
|
5
|
+
|
|
6
|
+
export async function build(args) {
|
|
7
|
+
let input = args['--input']
|
|
8
|
+
let shouldWatch = args['--watch']
|
|
9
|
+
|
|
10
|
+
// TODO: Deprecate this in future versions
|
|
11
|
+
if (!input && args['_'][1]) {
|
|
12
|
+
console.error('[deprecation] Running tailwindcss without -i, please provide an input file.')
|
|
13
|
+
input = args['--input'] = args['_'][1]
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
if (input && input !== '-' && !fs.existsSync((input = path.resolve(input)))) {
|
|
17
|
+
console.error(`Specified input file ${args['--input']} does not exist.`)
|
|
18
|
+
process.exit(9)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
if (args['--config'] && !fs.existsSync((args['--config'] = path.resolve(args['--config'])))) {
|
|
22
|
+
console.error(`Specified config file ${args['--config']} does not exist.`)
|
|
23
|
+
process.exit(9)
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// TODO: Reference the @config path here if exists
|
|
27
|
+
let configPath = args['--config'] ? args['--config'] : resolveDefaultConfigPath()
|
|
28
|
+
|
|
29
|
+
let processor = await createProcessor(args, configPath)
|
|
30
|
+
|
|
31
|
+
if (shouldWatch) {
|
|
32
|
+
// Abort the watcher if stdin is closed to avoid zombie processes
|
|
33
|
+
// You can disable this behavior with --watch=always
|
|
34
|
+
if (args['--watch'] !== 'always') {
|
|
35
|
+
process.stdin.on('end', () => process.exit(0))
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
process.stdin.resume()
|
|
39
|
+
|
|
40
|
+
await processor.watch()
|
|
41
|
+
} else {
|
|
42
|
+
await processor.build().catch((e) => {
|
|
43
|
+
console.error(e)
|
|
44
|
+
process.exit(1)
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
}
|