tailwindcss 0.0.0-insiders.7b94fea → 0.0.0-insiders.7d8eb21
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/CHANGELOG.md +588 -3
- package/LICENSE +1 -2
- package/README.md +15 -7
- package/colors.d.ts +3 -0
- package/colors.js +2 -1
- package/defaultConfig.d.ts +3 -0
- package/defaultConfig.js +2 -1
- package/defaultTheme.d.ts +4 -0
- package/defaultTheme.js +2 -1
- package/lib/cli/build/deps.js +54 -0
- package/lib/cli/build/index.js +48 -0
- package/lib/cli/build/plugin.js +362 -0
- package/lib/cli/build/utils.js +78 -0
- package/lib/cli/build/watching.js +178 -0
- package/lib/cli/help/index.js +71 -0
- package/lib/cli/index.js +18 -0
- package/lib/cli/init/index.js +46 -0
- package/lib/cli/shared.js +12 -0
- package/lib/cli-peer-dependencies.js +20 -7
- package/lib/cli.js +108 -571
- package/lib/constants.js +27 -20
- package/lib/corePluginList.js +15 -4
- package/lib/corePlugins.js +2229 -1868
- package/lib/css/preflight.css +22 -9
- package/lib/featureFlags.js +39 -25
- package/lib/index.js +28 -12
- package/lib/lib/cacheInvalidation.js +90 -0
- package/lib/lib/collapseAdjacentRules.js +28 -10
- 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 +27 -3
- package/lib/lib/evaluateTailwindFunctions.js +117 -50
- package/lib/lib/expandApplyAtRules.js +457 -159
- package/lib/lib/expandTailwindAtRules.js +130 -127
- package/lib/lib/findAtConfigPath.js +44 -0
- package/lib/lib/generateRules.js +610 -141
- package/lib/lib/getModuleDependencies.js +11 -8
- package/lib/lib/normalizeTailwindDirectives.js +43 -32
- package/lib/lib/offsets.js +285 -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 +114 -81
- package/lib/lib/setupContextUtils.js +718 -323
- package/lib/lib/setupTrackingContext.js +43 -71
- package/lib/lib/sharedState.js +50 -9
- package/lib/lib/substituteScreenAtRules.js +13 -8
- 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 +36 -21
- package/lib/public/colors.js +247 -245
- package/lib/public/create-plugin.js +6 -4
- package/lib/public/default-config.js +7 -5
- package/lib/public/default-theme.js +7 -5
- package/lib/public/resolve-config.js +8 -5
- package/lib/util/bigSign.js +4 -1
- package/lib/util/buildMediaQuery.js +18 -24
- package/lib/util/cloneDeep.js +7 -6
- package/lib/util/cloneNodes.js +21 -3
- package/lib/util/color.js +54 -40
- package/lib/util/configurePlugins.js +5 -2
- package/lib/util/createPlugin.js +6 -6
- package/lib/util/createUtilityPlugin.js +12 -14
- package/lib/util/dataTypes.js +164 -100
- package/lib/util/defaults.js +12 -3
- package/lib/util/escapeClassName.js +9 -6
- package/lib/util/escapeCommas.js +5 -2
- package/lib/util/flattenColorPalette.js +9 -12
- package/lib/util/formatVariantSelector.js +353 -0
- package/lib/util/getAllConfigs.js +29 -10
- package/lib/util/hashConfig.js +6 -3
- package/lib/util/isKeyframeRule.js +5 -2
- package/lib/util/isPlainObject.js +5 -2
- package/lib/util/isSyntacticallyValidPropertyValue.js +72 -0
- package/lib/util/log.js +22 -12
- package/lib/util/nameClass.js +20 -8
- package/lib/util/negateValue.js +23 -6
- package/lib/util/normalizeConfig.js +147 -60
- package/lib/util/normalizeScreens.js +170 -0
- package/lib/util/parseAnimationValue.js +42 -40
- package/lib/util/parseBoxShadowValue.js +84 -0
- package/lib/util/parseDependency.js +38 -56
- package/lib/util/parseGlob.js +34 -0
- package/lib/util/parseObjectStyles.js +11 -8
- package/lib/util/pluginUtils.js +182 -181
- package/lib/util/prefixSelector.js +27 -13
- package/lib/util/removeAlphaVariables.js +29 -0
- package/lib/util/resolveConfig.js +97 -73
- package/lib/util/resolveConfigPath.js +11 -9
- package/lib/util/responsive.js +8 -5
- package/lib/util/splitAtTopLevelOnly.js +43 -0
- package/lib/util/tap.js +4 -1
- package/lib/util/toColorValue.js +5 -3
- package/lib/util/toPath.js +24 -3
- package/lib/util/transformThemeValue.js +49 -31
- package/lib/util/validateConfig.js +24 -0
- package/lib/util/validateFormalSyntax.js +24 -0
- package/lib/util/withAlphaVariable.js +23 -15
- package/nesting/index.js +2 -12
- package/package.json +51 -50
- package/peers/index.js +15019 -12583
- package/plugin.d.ts +11 -0
- package/plugin.js +2 -1
- package/resolveConfig.d.ts +12 -0
- package/resolveConfig.js +2 -1
- package/scripts/generate-types.js +105 -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 +434 -0
- package/src/cli/build/utils.js +76 -0
- package/src/cli/build/watching.js +227 -0
- package/src/cli/help/index.js +70 -0
- package/src/cli/index.js +3 -0
- package/src/cli/init/index.js +50 -0
- package/src/cli/shared.js +5 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +50 -577
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +886 -598
- package/src/css/preflight.css +22 -9
- package/src/featureFlags.js +24 -8
- package/src/index.js +19 -6
- 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 +213 -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 +508 -153
- package/src/lib/expandTailwindAtRules.js +82 -79
- package/src/lib/findAtConfigPath.js +48 -0
- package/src/lib/generateRules.js +625 -111
- package/src/lib/normalizeTailwindDirectives.js +7 -1
- package/src/lib/offsets.js +351 -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 +98 -60
- package/src/lib/setupContextUtils.js +666 -168
- package/src/lib/setupTrackingContext.js +16 -52
- package/src/lib/sharedState.js +44 -4
- package/src/lib/substituteScreenAtRules.js +6 -3
- 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 +17 -2
- package/src/util/buildMediaQuery.js +14 -16
- package/src/util/cloneNodes.js +19 -2
- package/src/util/color.js +31 -14
- package/src/util/createUtilityPlugin.js +2 -2
- package/src/util/dataTypes.js +86 -21
- package/src/util/defaults.js +6 -0
- package/src/util/formatVariantSelector.js +412 -0
- package/src/util/getAllConfigs.js +19 -0
- package/src/util/isSyntacticallyValidPropertyValue.js +61 -0
- package/src/util/log.js +11 -7
- package/src/util/nameClass.js +6 -2
- package/src/util/negateValue.js +14 -4
- package/src/util/normalizeConfig.js +72 -5
- package/src/util/normalizeScreens.js +140 -0
- package/src/util/parseBoxShadowValue.js +72 -0
- package/src/util/parseDependency.js +37 -42
- package/src/util/parseGlob.js +24 -0
- package/src/util/pluginUtils.js +169 -143
- package/src/util/prefixSelector.js +30 -13
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +81 -27
- package/src/util/splitAtTopLevelOnly.js +45 -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 +1 -1
- package/stubs/defaultConfig.stub.js +246 -213
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +363 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +276 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/generated/default-theme.d.ts +342 -0
- package/types/index.d.ts +7 -0
- package/lib/lib/setupWatchingContext.js +0 -284
- package/nesting/plugin.js +0 -41
- package/src/lib/setupWatchingContext.js +0 -304
package/src/cli.js
CHANGED
|
@@ -1,113 +1,35 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
|
-
import { postcss, lazyCssnano, lazyAutoprefixer } from '../peers/index.js'
|
|
4
|
-
|
|
5
|
-
import chokidar from 'chokidar'
|
|
6
3
|
import path from 'path'
|
|
7
4
|
import arg from 'arg'
|
|
8
5
|
import fs from 'fs'
|
|
9
|
-
import postcssrc from 'postcss-load-config'
|
|
10
|
-
import { cosmiconfig } from 'cosmiconfig'
|
|
11
|
-
import loadPlugins from 'postcss-load-config/src/plugins' // Little bit scary, looking at private/internal API
|
|
12
|
-
import tailwind from './processTailwindFeatures'
|
|
13
|
-
import resolveConfigInternal from '../resolveConfig'
|
|
14
|
-
import fastGlob from 'fast-glob'
|
|
15
|
-
import getModuleDependencies from './lib/getModuleDependencies'
|
|
16
|
-
import log from './util/log'
|
|
17
|
-
import packageJson from '../package.json'
|
|
18
|
-
import normalizePath from 'normalize-path'
|
|
19
6
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}
|
|
7
|
+
import { build } from './cli/build'
|
|
8
|
+
import { help } from './cli/help'
|
|
9
|
+
import { init } from './cli/init'
|
|
23
10
|
|
|
24
|
-
|
|
11
|
+
function isESM() {
|
|
12
|
+
const pkgPath = path.resolve('./package.json')
|
|
25
13
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
child.raws.after = `\n${' '.repeat(indent)}`
|
|
33
|
-
indentRecursive(child, indent + 1)
|
|
34
|
-
})
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
function formatNodes(root) {
|
|
38
|
-
indentRecursive(root)
|
|
39
|
-
if (root.first) {
|
|
40
|
-
root.first.raws.before = ''
|
|
14
|
+
try {
|
|
15
|
+
let pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8'))
|
|
16
|
+
return pkg.type && pkg.type === 'module'
|
|
17
|
+
} catch (err) {
|
|
18
|
+
return false
|
|
41
19
|
}
|
|
42
20
|
}
|
|
43
21
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
console.log()
|
|
49
|
-
console.log(`${packageJson.name} v${packageJson.version}`)
|
|
50
|
-
|
|
51
|
-
// Render message
|
|
52
|
-
if (message) {
|
|
53
|
-
console.log()
|
|
54
|
-
for (let msg of message.split('\n')) {
|
|
55
|
-
console.log(msg)
|
|
22
|
+
let configs = isESM()
|
|
23
|
+
? {
|
|
24
|
+
tailwind: 'tailwind.config.cjs',
|
|
25
|
+
postcss: 'postcss.config.cjs',
|
|
56
26
|
}
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
if (usage && usage.length > 0) {
|
|
61
|
-
console.log()
|
|
62
|
-
console.log('Usage:')
|
|
63
|
-
for (let example of usage) {
|
|
64
|
-
console.log(' '.repeat(indent), example)
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
// Render commands
|
|
69
|
-
if (commands && commands.length > 0) {
|
|
70
|
-
console.log()
|
|
71
|
-
console.log('Commands:')
|
|
72
|
-
for (let command of commands) {
|
|
73
|
-
console.log(' '.repeat(indent), command)
|
|
27
|
+
: {
|
|
28
|
+
tailwind: 'tailwind.config.js',
|
|
29
|
+
postcss: 'postcss.config.js',
|
|
74
30
|
}
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
// Render options
|
|
78
|
-
if (options) {
|
|
79
|
-
let groupedOptions = {}
|
|
80
|
-
for (let [key, value] of Object.entries(options)) {
|
|
81
|
-
if (typeof value === 'object') {
|
|
82
|
-
groupedOptions[key] = { ...value, flags: [key] }
|
|
83
|
-
} else {
|
|
84
|
-
groupedOptions[value].flags.push(key)
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
console.log()
|
|
89
|
-
console.log('Options:')
|
|
90
|
-
for (let { flags, description, deprecated } of Object.values(groupedOptions)) {
|
|
91
|
-
if (deprecated) continue
|
|
92
31
|
|
|
93
|
-
|
|
94
|
-
console.log(
|
|
95
|
-
' '.repeat(indent + 4 /* 4 = "-i, ".length */),
|
|
96
|
-
flags.slice().reverse().join(', ').padEnd(20, ' '),
|
|
97
|
-
description
|
|
98
|
-
)
|
|
99
|
-
} else {
|
|
100
|
-
console.log(
|
|
101
|
-
' '.repeat(indent),
|
|
102
|
-
flags.slice().reverse().join(', ').padEnd(24, ' '),
|
|
103
|
-
description
|
|
104
|
-
)
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
console.log()
|
|
110
|
-
}
|
|
32
|
+
// ---
|
|
111
33
|
|
|
112
34
|
function oneOf(...options) {
|
|
113
35
|
return Object.assign(
|
|
@@ -129,8 +51,8 @@ let commands = {
|
|
|
129
51
|
init: {
|
|
130
52
|
run: init,
|
|
131
53
|
args: {
|
|
132
|
-
'--full': { type: Boolean, description:
|
|
133
|
-
'--postcss': { type: Boolean, description:
|
|
54
|
+
'--full': { type: Boolean, description: `Initialize a full \`${configs.tailwind}\` file` },
|
|
55
|
+
'--postcss': { type: Boolean, description: `Initialize a \`${configs.postcss}\` file` },
|
|
134
56
|
'-f': '--full',
|
|
135
57
|
'-p': '--postcss',
|
|
136
58
|
},
|
|
@@ -140,7 +62,14 @@ let commands = {
|
|
|
140
62
|
args: {
|
|
141
63
|
'--input': { type: String, description: 'Input file' },
|
|
142
64
|
'--output': { type: String, description: 'Output file' },
|
|
143
|
-
'--watch': {
|
|
65
|
+
'--watch': {
|
|
66
|
+
type: oneOf(String, Boolean),
|
|
67
|
+
description: 'Watch for changes and rebuild as needed',
|
|
68
|
+
},
|
|
69
|
+
'--poll': {
|
|
70
|
+
type: Boolean,
|
|
71
|
+
description: 'Use polling instead of filesystem events when watching',
|
|
72
|
+
},
|
|
144
73
|
'--content': {
|
|
145
74
|
type: String,
|
|
146
75
|
description: 'Content paths to use for removing unused classes',
|
|
@@ -167,6 +96,7 @@ let commands = {
|
|
|
167
96
|
'-o': '--output',
|
|
168
97
|
'-m': '--minify',
|
|
169
98
|
'-w': '--watch',
|
|
99
|
+
'-p': '--poll',
|
|
170
100
|
},
|
|
171
101
|
},
|
|
172
102
|
}
|
|
@@ -232,8 +162,8 @@ let args = (() => {
|
|
|
232
162
|
let flag = result['_'][i]
|
|
233
163
|
if (!flag.startsWith('-')) continue
|
|
234
164
|
|
|
235
|
-
let flagName = flag
|
|
236
|
-
let handler = flags[
|
|
165
|
+
let [flagName, flagValue] = flag.split('=')
|
|
166
|
+
let handler = flags[flagName]
|
|
237
167
|
|
|
238
168
|
// Resolve flagName & handler
|
|
239
169
|
while (typeof handler === 'string') {
|
|
@@ -246,19 +176,27 @@ let args = (() => {
|
|
|
246
176
|
let args = []
|
|
247
177
|
let offset = i + 1
|
|
248
178
|
|
|
249
|
-
//
|
|
250
|
-
|
|
251
|
-
args
|
|
252
|
-
|
|
179
|
+
// --flag value syntax was used so we need to pull `value` from `args`
|
|
180
|
+
if (flagValue === undefined) {
|
|
181
|
+
// Parse args for current flag
|
|
182
|
+
while (result['_'][offset] && !result['_'][offset].startsWith('-')) {
|
|
183
|
+
args.push(result['_'][offset++])
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
// Cleanup manually parsed flags + args
|
|
187
|
+
result['_'].splice(i, 1 + args.length)
|
|
253
188
|
|
|
254
|
-
|
|
255
|
-
|
|
189
|
+
// No args were provided, use default value defined in handler
|
|
190
|
+
// One arg was provided, use that directly
|
|
191
|
+
// Multiple args were provided so pass them all in an array
|
|
192
|
+
flagValue = args.length === 0 ? undefined : args.length === 1 ? args[0] : args
|
|
193
|
+
} else {
|
|
194
|
+
// Remove the whole flag from the args array
|
|
195
|
+
result['_'].splice(i, 1)
|
|
196
|
+
}
|
|
256
197
|
|
|
257
198
|
// Set the resolved value in the `result` object
|
|
258
|
-
result[flagName] = handler.type(
|
|
259
|
-
args.length === 0 ? undefined : args.length === 1 ? args[0] : args,
|
|
260
|
-
flagName
|
|
261
|
-
)
|
|
199
|
+
result[flagName] = handler.type(flagValue, flagName)
|
|
262
200
|
}
|
|
263
201
|
|
|
264
202
|
// Ensure that the `command` is always the first argument in the `args`.
|
|
@@ -293,469 +231,4 @@ if (args['--help']) {
|
|
|
293
231
|
process.exit(0)
|
|
294
232
|
}
|
|
295
233
|
|
|
296
|
-
run()
|
|
297
|
-
|
|
298
|
-
// ---
|
|
299
|
-
|
|
300
|
-
function init() {
|
|
301
|
-
let messages = []
|
|
302
|
-
|
|
303
|
-
let tailwindConfigLocation = path.resolve(args['_'][1] ?? './tailwind.config.js')
|
|
304
|
-
if (fs.existsSync(tailwindConfigLocation)) {
|
|
305
|
-
messages.push(`${path.basename(tailwindConfigLocation)} already exists.`)
|
|
306
|
-
} else {
|
|
307
|
-
let stubFile = fs.readFileSync(
|
|
308
|
-
args['--full']
|
|
309
|
-
? path.resolve(__dirname, '../stubs/defaultConfig.stub.js')
|
|
310
|
-
: path.resolve(__dirname, '../stubs/simpleConfig.stub.js'),
|
|
311
|
-
'utf8'
|
|
312
|
-
)
|
|
313
|
-
|
|
314
|
-
// Change colors import
|
|
315
|
-
stubFile = stubFile.replace('../colors', 'tailwindcss/colors')
|
|
316
|
-
|
|
317
|
-
fs.writeFileSync(tailwindConfigLocation, stubFile, 'utf8')
|
|
318
|
-
|
|
319
|
-
messages.push(`Created Tailwind CSS config file: ${path.basename(tailwindConfigLocation)}`)
|
|
320
|
-
}
|
|
321
|
-
|
|
322
|
-
if (args['--postcss']) {
|
|
323
|
-
let postcssConfigLocation = path.resolve('./postcss.config.js')
|
|
324
|
-
if (fs.existsSync(postcssConfigLocation)) {
|
|
325
|
-
messages.push(`${path.basename(postcssConfigLocation)} already exists.`)
|
|
326
|
-
} else {
|
|
327
|
-
let stubFile = fs.readFileSync(
|
|
328
|
-
path.resolve(__dirname, '../stubs/defaultPostCssConfig.stub.js'),
|
|
329
|
-
'utf8'
|
|
330
|
-
)
|
|
331
|
-
|
|
332
|
-
fs.writeFileSync(postcssConfigLocation, stubFile, 'utf8')
|
|
333
|
-
|
|
334
|
-
messages.push(`Created PostCSS config file: ${path.basename(postcssConfigLocation)}`)
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
|
|
338
|
-
if (messages.length > 0) {
|
|
339
|
-
console.log()
|
|
340
|
-
for (let message of messages) {
|
|
341
|
-
console.log(message)
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
async function build() {
|
|
347
|
-
let input = args['--input']
|
|
348
|
-
let output = args['--output']
|
|
349
|
-
let shouldWatch = args['--watch']
|
|
350
|
-
let includePostCss = args['--postcss']
|
|
351
|
-
|
|
352
|
-
// TODO: Deprecate this in future versions
|
|
353
|
-
if (!input && args['_'][1]) {
|
|
354
|
-
console.error('[deprecation] Running tailwindcss without -i, please provide an input file.')
|
|
355
|
-
input = args['--input'] = args['_'][1]
|
|
356
|
-
}
|
|
357
|
-
|
|
358
|
-
if (input && !fs.existsSync((input = path.resolve(input)))) {
|
|
359
|
-
console.error(`Specified input file ${args['--input']} does not exist.`)
|
|
360
|
-
process.exit(9)
|
|
361
|
-
}
|
|
362
|
-
|
|
363
|
-
if (args['--config'] && !fs.existsSync((args['--config'] = path.resolve(args['--config'])))) {
|
|
364
|
-
console.error(`Specified config file ${args['--config']} does not exist.`)
|
|
365
|
-
process.exit(9)
|
|
366
|
-
}
|
|
367
|
-
|
|
368
|
-
let configPath = args['--config']
|
|
369
|
-
? args['--config']
|
|
370
|
-
: ((defaultPath) => (fs.existsSync(defaultPath) ? defaultPath : null))(
|
|
371
|
-
path.resolve('./tailwind.config.js')
|
|
372
|
-
)
|
|
373
|
-
|
|
374
|
-
async function loadPostCssPlugins() {
|
|
375
|
-
let customPostCssPath = typeof args['--postcss'] === 'string' ? args['--postcss'] : undefined
|
|
376
|
-
let { plugins: configPlugins } = customPostCssPath
|
|
377
|
-
? await (async () => {
|
|
378
|
-
let file = path.resolve(customPostCssPath)
|
|
379
|
-
|
|
380
|
-
// Implementation, see: https://unpkg.com/browse/postcss-load-config@3.0.1/src/index.js
|
|
381
|
-
let { config = {} } = await cosmiconfig('postcss').load(file)
|
|
382
|
-
if (typeof config === 'function') {
|
|
383
|
-
config = config()
|
|
384
|
-
} else {
|
|
385
|
-
config = Object.assign({}, config)
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
if (!config.plugins) {
|
|
389
|
-
config.plugins = []
|
|
390
|
-
}
|
|
391
|
-
|
|
392
|
-
return { plugins: loadPlugins(config, file) }
|
|
393
|
-
})()
|
|
394
|
-
: await postcssrc()
|
|
395
|
-
|
|
396
|
-
let configPluginTailwindIdx = configPlugins.findIndex((plugin) => {
|
|
397
|
-
if (typeof plugin === 'function' && plugin.name === 'tailwindcss') {
|
|
398
|
-
return true
|
|
399
|
-
}
|
|
400
|
-
|
|
401
|
-
if (typeof plugin === 'object' && plugin !== null && plugin.postcssPlugin === 'tailwindcss') {
|
|
402
|
-
return true
|
|
403
|
-
}
|
|
404
|
-
|
|
405
|
-
return false
|
|
406
|
-
})
|
|
407
|
-
|
|
408
|
-
let beforePlugins =
|
|
409
|
-
configPluginTailwindIdx === -1 ? [] : configPlugins.slice(0, configPluginTailwindIdx)
|
|
410
|
-
let afterPlugins =
|
|
411
|
-
configPluginTailwindIdx === -1
|
|
412
|
-
? configPlugins
|
|
413
|
-
: configPlugins.slice(configPluginTailwindIdx + 1)
|
|
414
|
-
|
|
415
|
-
return [beforePlugins, afterPlugins]
|
|
416
|
-
}
|
|
417
|
-
|
|
418
|
-
function resolveConfig() {
|
|
419
|
-
let config = configPath ? require(configPath) : {}
|
|
420
|
-
let resolvedConfig = resolveConfigInternal(config)
|
|
421
|
-
|
|
422
|
-
if (args['--purge']) {
|
|
423
|
-
log.warn('purge-flag-deprecated', [
|
|
424
|
-
'The `--purge` flag has been deprecated.',
|
|
425
|
-
'Please use `--content` instead.',
|
|
426
|
-
])
|
|
427
|
-
if (!args['--content']) {
|
|
428
|
-
args['--content'] = args['--purge']
|
|
429
|
-
}
|
|
430
|
-
}
|
|
431
|
-
|
|
432
|
-
if (args['--content']) {
|
|
433
|
-
resolvedConfig.content = args['--content'].split(/(?<!{[^}]+),/)
|
|
434
|
-
}
|
|
435
|
-
|
|
436
|
-
return resolvedConfig
|
|
437
|
-
}
|
|
438
|
-
|
|
439
|
-
function extractFileGlobs(config) {
|
|
440
|
-
return config.content.files
|
|
441
|
-
.filter((file) => {
|
|
442
|
-
// Strings in this case are files / globs. If it is something else,
|
|
443
|
-
// like an object it's probably a raw content object. But this object
|
|
444
|
-
// is not watchable, so let's remove it.
|
|
445
|
-
return typeof file === 'string'
|
|
446
|
-
})
|
|
447
|
-
.map((glob) => normalizePath(glob))
|
|
448
|
-
}
|
|
449
|
-
|
|
450
|
-
function extractRawContent(config) {
|
|
451
|
-
return config.content.files.filter((file) => {
|
|
452
|
-
return typeof file === 'object' && file !== null
|
|
453
|
-
})
|
|
454
|
-
}
|
|
455
|
-
|
|
456
|
-
function getChangedContent(config) {
|
|
457
|
-
let changedContent = []
|
|
458
|
-
|
|
459
|
-
// Resolve globs from the content config
|
|
460
|
-
let globs = extractFileGlobs(config)
|
|
461
|
-
let files = fastGlob.sync(globs)
|
|
462
|
-
|
|
463
|
-
for (let file of files) {
|
|
464
|
-
changedContent.push({
|
|
465
|
-
content: fs.readFileSync(path.resolve(file), 'utf8'),
|
|
466
|
-
extension: path.extname(file).slice(1),
|
|
467
|
-
})
|
|
468
|
-
}
|
|
469
|
-
|
|
470
|
-
// Resolve raw content in the tailwind config
|
|
471
|
-
for (let { raw: content, extension = 'html' } of extractRawContent(config)) {
|
|
472
|
-
changedContent.push({ content, extension })
|
|
473
|
-
}
|
|
474
|
-
|
|
475
|
-
return changedContent
|
|
476
|
-
}
|
|
477
|
-
|
|
478
|
-
async function buildOnce() {
|
|
479
|
-
let config = resolveConfig()
|
|
480
|
-
let changedContent = getChangedContent(config)
|
|
481
|
-
|
|
482
|
-
let tailwindPlugin = () => {
|
|
483
|
-
return {
|
|
484
|
-
postcssPlugin: 'tailwindcss',
|
|
485
|
-
Once(root, { result }) {
|
|
486
|
-
tailwind(({ createContext }) => {
|
|
487
|
-
return () => {
|
|
488
|
-
return createContext(config, changedContent)
|
|
489
|
-
}
|
|
490
|
-
})(root, result)
|
|
491
|
-
},
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
|
|
495
|
-
tailwindPlugin.postcss = true
|
|
496
|
-
|
|
497
|
-
let [beforePlugins, afterPlugins] = includePostCss ? await loadPostCssPlugins() : [[], []]
|
|
498
|
-
|
|
499
|
-
let plugins = [
|
|
500
|
-
...beforePlugins,
|
|
501
|
-
tailwindPlugin,
|
|
502
|
-
!args['--minify'] && formatNodes,
|
|
503
|
-
...afterPlugins,
|
|
504
|
-
!args['--no-autoprefixer'] &&
|
|
505
|
-
(() => {
|
|
506
|
-
// Try to load a local `autoprefixer` version first
|
|
507
|
-
try {
|
|
508
|
-
return require('autoprefixer')
|
|
509
|
-
} catch {}
|
|
510
|
-
|
|
511
|
-
return lazyAutoprefixer()
|
|
512
|
-
})(),
|
|
513
|
-
args['--minify'] &&
|
|
514
|
-
(() => {
|
|
515
|
-
let options = { preset: ['default', { cssDeclarationSorter: false }] }
|
|
516
|
-
|
|
517
|
-
// Try to load a local `cssnano` version first
|
|
518
|
-
try {
|
|
519
|
-
return require('cssnano')
|
|
520
|
-
} catch {}
|
|
521
|
-
|
|
522
|
-
return lazyCssnano()(options)
|
|
523
|
-
})(),
|
|
524
|
-
].filter(Boolean)
|
|
525
|
-
|
|
526
|
-
let processor = postcss(plugins)
|
|
527
|
-
|
|
528
|
-
function processCSS(css) {
|
|
529
|
-
let start = process.hrtime.bigint()
|
|
530
|
-
return Promise.resolve()
|
|
531
|
-
.then(() => (output ? fs.promises.mkdir(path.dirname(output), { recursive: true }) : null))
|
|
532
|
-
.then(() => processor.process(css, { from: input, to: output }))
|
|
533
|
-
.then((result) => {
|
|
534
|
-
if (!output) {
|
|
535
|
-
return process.stdout.write(result.css)
|
|
536
|
-
}
|
|
537
|
-
return Promise.all(
|
|
538
|
-
[
|
|
539
|
-
fs.promises.writeFile(output, result.css, () => true),
|
|
540
|
-
result.map && fs.writeFile(output + '.map', result.map.toString(), () => true),
|
|
541
|
-
].filter(Boolean)
|
|
542
|
-
)
|
|
543
|
-
})
|
|
544
|
-
.then(() => {
|
|
545
|
-
let end = process.hrtime.bigint()
|
|
546
|
-
console.error()
|
|
547
|
-
console.error('Done in', (end - start) / BigInt(1e6) + 'ms.')
|
|
548
|
-
})
|
|
549
|
-
}
|
|
550
|
-
|
|
551
|
-
let css = input
|
|
552
|
-
? fs.readFileSync(path.resolve(input), 'utf8')
|
|
553
|
-
: '@tailwind base; @tailwind components; @tailwind utilities'
|
|
554
|
-
return processCSS(css)
|
|
555
|
-
}
|
|
556
|
-
|
|
557
|
-
let context = null
|
|
558
|
-
|
|
559
|
-
async function startWatcher() {
|
|
560
|
-
let changedContent = []
|
|
561
|
-
let configDependencies = []
|
|
562
|
-
let contextDependencies = new Set()
|
|
563
|
-
let watcher = null
|
|
564
|
-
|
|
565
|
-
function refreshConfig() {
|
|
566
|
-
env.DEBUG && console.time('Module dependencies')
|
|
567
|
-
for (let file of configDependencies) {
|
|
568
|
-
delete require.cache[require.resolve(file)]
|
|
569
|
-
}
|
|
570
|
-
|
|
571
|
-
if (configPath) {
|
|
572
|
-
configDependencies = getModuleDependencies(configPath).map(({ file }) => file)
|
|
573
|
-
|
|
574
|
-
for (let dependency of configDependencies) {
|
|
575
|
-
contextDependencies.add(dependency)
|
|
576
|
-
}
|
|
577
|
-
}
|
|
578
|
-
env.DEBUG && console.timeEnd('Module dependencies')
|
|
579
|
-
|
|
580
|
-
return resolveConfig()
|
|
581
|
-
}
|
|
582
|
-
|
|
583
|
-
let [beforePlugins, afterPlugins] = includePostCss ? await loadPostCssPlugins() : [[], []]
|
|
584
|
-
|
|
585
|
-
let plugins = [
|
|
586
|
-
...beforePlugins,
|
|
587
|
-
'__TAILWIND_PLUGIN_POSITION__',
|
|
588
|
-
!args['--minify'] && formatNodes,
|
|
589
|
-
...afterPlugins,
|
|
590
|
-
!args['--no-autoprefixer'] &&
|
|
591
|
-
(() => {
|
|
592
|
-
// Try to load a local `autoprefixer` version first
|
|
593
|
-
try {
|
|
594
|
-
return require('autoprefixer')
|
|
595
|
-
} catch {}
|
|
596
|
-
|
|
597
|
-
return lazyAutoprefixer()
|
|
598
|
-
})(),
|
|
599
|
-
args['--minify'] &&
|
|
600
|
-
(() => {
|
|
601
|
-
let options = { preset: ['default', { cssDeclarationSorter: false }] }
|
|
602
|
-
|
|
603
|
-
// Try to load a local `cssnano` version first
|
|
604
|
-
try {
|
|
605
|
-
return require('cssnano')
|
|
606
|
-
} catch {}
|
|
607
|
-
|
|
608
|
-
return lazyCssnano()(options)
|
|
609
|
-
})(),
|
|
610
|
-
].filter(Boolean)
|
|
611
|
-
|
|
612
|
-
async function rebuild(config) {
|
|
613
|
-
env.DEBUG && console.time('Finished in')
|
|
614
|
-
|
|
615
|
-
let tailwindPlugin = () => {
|
|
616
|
-
return {
|
|
617
|
-
postcssPlugin: 'tailwindcss',
|
|
618
|
-
Once(root, { result }) {
|
|
619
|
-
env.DEBUG && console.time('Compiling CSS')
|
|
620
|
-
tailwind(({ createContext }) => {
|
|
621
|
-
console.error()
|
|
622
|
-
console.error('Rebuilding...')
|
|
623
|
-
|
|
624
|
-
return () => {
|
|
625
|
-
if (context !== null) {
|
|
626
|
-
context.changedContent = changedContent.splice(0)
|
|
627
|
-
return context
|
|
628
|
-
}
|
|
629
|
-
|
|
630
|
-
env.DEBUG && console.time('Creating context')
|
|
631
|
-
context = createContext(config, changedContent.splice(0))
|
|
632
|
-
env.DEBUG && console.timeEnd('Creating context')
|
|
633
|
-
return context
|
|
634
|
-
}
|
|
635
|
-
})(root, result)
|
|
636
|
-
env.DEBUG && console.timeEnd('Compiling CSS')
|
|
637
|
-
},
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
|
|
641
|
-
tailwindPlugin.postcss = true
|
|
642
|
-
|
|
643
|
-
let tailwindPluginIdx = plugins.indexOf('__TAILWIND_PLUGIN_POSITION__')
|
|
644
|
-
let copy = plugins.slice()
|
|
645
|
-
copy.splice(tailwindPluginIdx, 1, tailwindPlugin)
|
|
646
|
-
let processor = postcss(copy)
|
|
647
|
-
|
|
648
|
-
function processCSS(css) {
|
|
649
|
-
let start = process.hrtime.bigint()
|
|
650
|
-
return Promise.resolve()
|
|
651
|
-
.then(() =>
|
|
652
|
-
output ? fs.promises.mkdir(path.dirname(output), { recursive: true }) : null
|
|
653
|
-
)
|
|
654
|
-
.then(() => processor.process(css, { from: input, to: output }))
|
|
655
|
-
.then(async (result) => {
|
|
656
|
-
for (let message of result.messages) {
|
|
657
|
-
if (message.type === 'dependency') {
|
|
658
|
-
contextDependencies.add(message.file)
|
|
659
|
-
}
|
|
660
|
-
}
|
|
661
|
-
watcher.add([...contextDependencies])
|
|
662
|
-
|
|
663
|
-
if (!output) {
|
|
664
|
-
return process.stdout.write(result.css)
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
await Promise.all(
|
|
668
|
-
[
|
|
669
|
-
fs.promises.writeFile(output, result.css, () => true),
|
|
670
|
-
result.map && fs.writeFile(output + '.map', result.map.toString(), () => true),
|
|
671
|
-
].filter(Boolean)
|
|
672
|
-
)
|
|
673
|
-
})
|
|
674
|
-
.then(() => {
|
|
675
|
-
let end = process.hrtime.bigint()
|
|
676
|
-
console.error('Done in', (end - start) / BigInt(1e6) + 'ms.')
|
|
677
|
-
})
|
|
678
|
-
.catch((err) => {
|
|
679
|
-
if (err.name === 'CssSyntaxError') {
|
|
680
|
-
console.error(err.toString())
|
|
681
|
-
} else {
|
|
682
|
-
console.error(err)
|
|
683
|
-
}
|
|
684
|
-
})
|
|
685
|
-
}
|
|
686
|
-
|
|
687
|
-
let css = input
|
|
688
|
-
? fs.readFileSync(path.resolve(input), 'utf8')
|
|
689
|
-
: '@tailwind base; @tailwind components; @tailwind utilities'
|
|
690
|
-
let result = await processCSS(css)
|
|
691
|
-
env.DEBUG && console.timeEnd('Finished in')
|
|
692
|
-
return result
|
|
693
|
-
}
|
|
694
|
-
|
|
695
|
-
let config = refreshConfig(configPath)
|
|
696
|
-
|
|
697
|
-
if (input) {
|
|
698
|
-
contextDependencies.add(path.resolve(input))
|
|
699
|
-
}
|
|
700
|
-
|
|
701
|
-
watcher = chokidar.watch([...contextDependencies, ...extractFileGlobs(config)], {
|
|
702
|
-
ignoreInitial: true,
|
|
703
|
-
})
|
|
704
|
-
|
|
705
|
-
let chain = Promise.resolve()
|
|
706
|
-
|
|
707
|
-
watcher.on('change', async (file) => {
|
|
708
|
-
if (contextDependencies.has(file)) {
|
|
709
|
-
env.DEBUG && console.time('Resolve config')
|
|
710
|
-
context = null
|
|
711
|
-
config = refreshConfig(configPath)
|
|
712
|
-
env.DEBUG && console.timeEnd('Resolve config')
|
|
713
|
-
|
|
714
|
-
env.DEBUG && console.time('Watch new files')
|
|
715
|
-
let globs = extractFileGlobs(config)
|
|
716
|
-
watcher.add(configDependencies)
|
|
717
|
-
watcher.add(globs)
|
|
718
|
-
env.DEBUG && console.timeEnd('Watch new files')
|
|
719
|
-
|
|
720
|
-
chain = chain.then(async () => {
|
|
721
|
-
changedContent.push(...getChangedContent(config))
|
|
722
|
-
await rebuild(config)
|
|
723
|
-
})
|
|
724
|
-
} else {
|
|
725
|
-
chain = chain.then(async () => {
|
|
726
|
-
changedContent.push({
|
|
727
|
-
content: fs.readFileSync(path.resolve(file), 'utf8'),
|
|
728
|
-
extension: path.extname(file).slice(1),
|
|
729
|
-
})
|
|
730
|
-
|
|
731
|
-
await rebuild(config)
|
|
732
|
-
})
|
|
733
|
-
}
|
|
734
|
-
})
|
|
735
|
-
|
|
736
|
-
watcher.on('add', async (file) => {
|
|
737
|
-
chain = chain.then(async () => {
|
|
738
|
-
changedContent.push({
|
|
739
|
-
content: fs.readFileSync(path.resolve(file), 'utf8'),
|
|
740
|
-
extension: path.extname(file).slice(1),
|
|
741
|
-
})
|
|
742
|
-
|
|
743
|
-
await rebuild(config)
|
|
744
|
-
})
|
|
745
|
-
})
|
|
746
|
-
|
|
747
|
-
chain = chain.then(() => {
|
|
748
|
-
changedContent.push(...getChangedContent(config))
|
|
749
|
-
return rebuild(config)
|
|
750
|
-
})
|
|
751
|
-
}
|
|
752
|
-
|
|
753
|
-
if (shouldWatch) {
|
|
754
|
-
/* Abort the watcher if stdin is closed to avoid zombie processes */
|
|
755
|
-
process.stdin.on('end', () => process.exit(0))
|
|
756
|
-
process.stdin.resume()
|
|
757
|
-
startWatcher()
|
|
758
|
-
} else {
|
|
759
|
-
buildOnce()
|
|
760
|
-
}
|
|
761
|
-
}
|
|
234
|
+
run(args, configs)
|
package/src/corePluginList.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export default ["preflight","container","accessibility","pointerEvents","visibility","position","inset","isolation","zIndex","order","gridColumn","gridColumnStart","gridColumnEnd","gridRow","gridRowStart","gridRowEnd","float","clear","margin","boxSizing","display","aspectRatio","height","maxHeight","minHeight","width","minWidth","maxWidth","flex","flexShrink","flexGrow","flexBasis","tableLayout","borderCollapse","transformOrigin","translate","rotate","skew","scale","transform","animation","cursor","touchAction","userSelect","resize","scrollSnapType","scrollSnapAlign","scrollSnapStop","scrollMargin","scrollPadding","listStylePosition","listStyleType","appearance","columns","breakBefore","breakInside","breakAfter","gridAutoColumns","gridAutoFlow","gridAutoRows","gridTemplateColumns","gridTemplateRows","flexDirection","flexWrap","placeContent","placeItems","alignContent","alignItems","justifyContent","justifyItems","gap","space","divideWidth","divideStyle","divideColor","divideOpacity","placeSelf","alignSelf","justifySelf","overflow","overscrollBehavior","scrollBehavior","textOverflow","whitespace","wordBreak","borderRadius","borderWidth","borderStyle","borderColor","borderOpacity","backgroundColor","backgroundOpacity","backgroundImage","gradientColorStops","boxDecorationBreak","backgroundSize","backgroundAttachment","backgroundClip","backgroundPosition","backgroundRepeat","backgroundOrigin","fill","stroke","strokeWidth","objectFit","objectPosition","padding","textAlign","textIndent","verticalAlign","fontFamily","fontSize","fontWeight","textTransform","fontStyle","fontVariantNumeric","lineHeight","letterSpacing","textColor","textOpacity","textDecoration","fontSmoothing","placeholderColor","placeholderOpacity","caretColor","accentColor","opacity","backgroundBlendMode","mixBlendMode","boxShadow","
|
|
1
|
+
export default ["preflight","container","accessibility","pointerEvents","visibility","position","inset","isolation","zIndex","order","gridColumn","gridColumnStart","gridColumnEnd","gridRow","gridRowStart","gridRowEnd","float","clear","margin","boxSizing","display","aspectRatio","height","maxHeight","minHeight","width","minWidth","maxWidth","flex","flexShrink","flexGrow","flexBasis","tableLayout","borderCollapse","borderSpacing","transformOrigin","translate","rotate","skew","scale","transform","animation","cursor","touchAction","userSelect","resize","scrollSnapType","scrollSnapAlign","scrollSnapStop","scrollMargin","scrollPadding","listStylePosition","listStyleType","appearance","columns","breakBefore","breakInside","breakAfter","gridAutoColumns","gridAutoFlow","gridAutoRows","gridTemplateColumns","gridTemplateRows","flexDirection","flexWrap","placeContent","placeItems","alignContent","alignItems","justifyContent","justifyItems","gap","space","divideWidth","divideStyle","divideColor","divideOpacity","placeSelf","alignSelf","justifySelf","overflow","overscrollBehavior","scrollBehavior","textOverflow","whitespace","wordBreak","borderRadius","borderWidth","borderStyle","borderColor","borderOpacity","backgroundColor","backgroundOpacity","backgroundImage","gradientColorStops","boxDecorationBreak","backgroundSize","backgroundAttachment","backgroundClip","backgroundPosition","backgroundRepeat","backgroundOrigin","fill","stroke","strokeWidth","objectFit","objectPosition","padding","textAlign","textIndent","verticalAlign","fontFamily","fontSize","fontWeight","textTransform","fontStyle","fontVariantNumeric","lineHeight","letterSpacing","textColor","textOpacity","textDecoration","textDecorationColor","textDecorationStyle","textDecorationThickness","textUnderlineOffset","fontSmoothing","placeholderColor","placeholderOpacity","caretColor","accentColor","opacity","backgroundBlendMode","mixBlendMode","boxShadow","boxShadowColor","outlineStyle","outlineWidth","outlineOffset","outlineColor","ringWidth","ringColor","ringOpacity","ringOffsetWidth","ringOffsetColor","blur","brightness","contrast","dropShadow","grayscale","hueRotate","invert","saturate","sepia","filter","backdropBlur","backdropBrightness","backdropContrast","backdropGrayscale","backdropHueRotate","backdropInvert","backdropOpacity","backdropSaturate","backdropSepia","backdropFilter","transitionProperty","transitionDelay","transitionDuration","transitionTimingFunction","willChange","content"]
|