tailwindcss 0.0.0-insiders.d58d5b2 → 0.0.0-insiders.d593a21
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/README.md +5 -10
- package/dist/chunk-FTZ4NPTT.mjs +37 -0
- package/dist/chunk-G32FJCSR.mjs +1 -0
- package/dist/chunk-HTB5LLOP.mjs +1 -0
- package/dist/colors-b_6i0Oi7.d.ts +295 -0
- package/dist/colors.d.mts +295 -0
- package/dist/colors.d.ts +5 -0
- package/dist/colors.js +1 -0
- package/dist/colors.mjs +1 -0
- package/dist/default-theme.d.mts +1147 -0
- package/dist/default-theme.d.ts +1147 -0
- package/dist/default-theme.js +1 -0
- package/dist/default-theme.mjs +1 -0
- package/dist/flatten-color-palette.d.mts +6 -0
- package/dist/flatten-color-palette.d.ts +6 -0
- package/dist/flatten-color-palette.js +3 -0
- package/dist/flatten-color-palette.mjs +1 -0
- package/dist/lib.d.mts +352 -0
- package/dist/lib.d.ts +3 -0
- package/dist/lib.js +37 -0
- package/dist/lib.mjs +1 -0
- package/dist/plugin.d.mts +11 -0
- package/dist/plugin.d.ts +131 -0
- package/dist/plugin.js +1 -0
- package/dist/plugin.mjs +1 -0
- package/dist/resolve-config-BIFUA2FY.d.ts +29 -0
- package/dist/resolve-config-QUZ9b-Gn.d.mts +190 -0
- package/dist/types-WlZgYgM8.d.mts +125 -0
- package/index.css +894 -3
- package/package.json +76 -100
- package/preflight.css +393 -0
- package/theme.css +462 -0
- package/base.css +0 -1
- package/colors.d.ts +0 -3
- package/colors.js +0 -2
- package/components.css +0 -1
- package/defaultConfig.d.ts +0 -3
- package/defaultConfig.js +0 -2
- package/defaultTheme.d.ts +0 -4
- package/defaultTheme.js +0 -2
- package/lib/cli/build/index.js +0 -57
- package/lib/cli/build/plugin.js +0 -431
- package/lib/cli/build/utils.js +0 -88
- package/lib/cli/build/watching.js +0 -182
- package/lib/cli/help/index.js +0 -73
- package/lib/cli/index.js +0 -231
- package/lib/cli/init/index.js +0 -63
- package/lib/cli.js +0 -3
- package/lib/corePluginList.js +0 -188
- package/lib/corePlugins.js +0 -4195
- package/lib/css/LICENSE +0 -25
- package/lib/css/preflight.css +0 -379
- package/lib/featureFlags.js +0 -85
- package/lib/index.js +0 -2
- package/lib/lib/cacheInvalidation.js +0 -92
- package/lib/lib/collapseAdjacentRules.js +0 -61
- package/lib/lib/collapseDuplicateDeclarations.js +0 -85
- package/lib/lib/content.js +0 -207
- package/lib/lib/defaultExtractor.js +0 -243
- package/lib/lib/detectNesting.js +0 -45
- package/lib/lib/evaluateTailwindFunctions.js +0 -238
- package/lib/lib/expandApplyAtRules.js +0 -534
- package/lib/lib/expandTailwindAtRules.js +0 -315
- package/lib/lib/findAtConfigPath.js +0 -46
- package/lib/lib/generateRules.js +0 -887
- package/lib/lib/getModuleDependencies.js +0 -99
- package/lib/lib/handleImportAtRules.js +0 -50
- package/lib/lib/load-config.js +0 -42
- package/lib/lib/normalizeTailwindDirectives.js +0 -74
- package/lib/lib/offsets.js +0 -306
- package/lib/lib/partitionApplyAtRules.js +0 -58
- package/lib/lib/regex.js +0 -74
- package/lib/lib/remap-bitfield.js +0 -89
- package/lib/lib/resolveDefaultsAtRules.js +0 -165
- package/lib/lib/setupContextUtils.js +0 -1270
- package/lib/lib/setupTrackingContext.js +0 -167
- package/lib/lib/sharedState.js +0 -79
- package/lib/lib/substituteScreenAtRules.js +0 -31
- package/lib/plugin.js +0 -164
- package/lib/postcss-plugins/nesting/README.md +0 -42
- package/lib/postcss-plugins/nesting/index.js +0 -21
- package/lib/postcss-plugins/nesting/plugin.js +0 -89
- package/lib/processTailwindFeatures.js +0 -64
- package/lib/public/colors.js +0 -355
- package/lib/public/create-plugin.js +0 -17
- package/lib/public/default-config.js +0 -18
- package/lib/public/default-theme.js +0 -18
- package/lib/public/load-config.js +0 -12
- package/lib/public/resolve-config.js +0 -24
- package/lib/util/applyImportantSelector.js +0 -36
- package/lib/util/bigSign.js +0 -13
- package/lib/util/buildMediaQuery.js +0 -27
- package/lib/util/cloneDeep.js +0 -22
- package/lib/util/cloneNodes.js +0 -34
- package/lib/util/color.js +0 -116
- package/lib/util/colorNames.js +0 -752
- package/lib/util/configurePlugins.js +0 -23
- package/lib/util/createPlugin.js +0 -32
- package/lib/util/createUtilityPlugin.js +0 -53
- package/lib/util/dataTypes.js +0 -358
- package/lib/util/defaults.js +0 -27
- package/lib/util/escapeClassName.js +0 -24
- package/lib/util/escapeCommas.js +0 -13
- package/lib/util/flattenColorPalette.js +0 -18
- package/lib/util/formatVariantSelector.js +0 -265
- package/lib/util/getAllConfigs.js +0 -51
- package/lib/util/hashConfig.js +0 -21
- package/lib/util/isKeyframeRule.js +0 -13
- package/lib/util/isPlainObject.js +0 -17
- package/lib/util/isSyntacticallyValidPropertyValue.js +0 -74
- package/lib/util/log.js +0 -78
- package/lib/util/nameClass.js +0 -49
- package/lib/util/negateValue.js +0 -36
- package/lib/util/normalizeConfig.js +0 -313
- package/lib/util/normalizeScreens.js +0 -178
- package/lib/util/parseAnimationValue.js +0 -93
- package/lib/util/parseBoxShadowValue.js +0 -88
- package/lib/util/parseDependency.js +0 -47
- package/lib/util/parseGlob.js +0 -36
- package/lib/util/parseObjectStyles.js +0 -36
- package/lib/util/pluginUtils.js +0 -274
- package/lib/util/prefixSelector.js +0 -39
- package/lib/util/pseudoElements.js +0 -209
- package/lib/util/removeAlphaVariables.js +0 -31
- package/lib/util/resolveConfig.js +0 -260
- package/lib/util/resolveConfigPath.js +0 -70
- package/lib/util/responsive.js +0 -24
- package/lib/util/splitAtTopLevelOnly.js +0 -51
- package/lib/util/tap.js +0 -14
- package/lib/util/toColorValue.js +0 -13
- package/lib/util/toPath.js +0 -32
- package/lib/util/transformThemeValue.js +0 -73
- package/lib/util/validateConfig.js +0 -48
- package/lib/util/validateFormalSyntax.js +0 -26
- package/lib/util/withAlphaVariable.js +0 -79
- package/lib/value-parser/LICENSE +0 -22
- package/lib/value-parser/README.md +0 -3
- package/lib/value-parser/index.d.js +0 -2
- package/lib/value-parser/index.js +0 -22
- package/lib/value-parser/parse.js +0 -259
- package/lib/value-parser/stringify.js +0 -38
- package/lib/value-parser/unit.js +0 -86
- package/lib/value-parser/walk.js +0 -16
- package/loadConfig.d.ts +0 -4
- package/loadConfig.js +0 -2
- package/nesting/index.js +0 -2
- package/plugin.d.ts +0 -11
- package/plugin.js +0 -2
- package/prettier.config.js +0 -19
- package/resolveConfig.d.ts +0 -12
- package/resolveConfig.js +0 -2
- package/screens.css +0 -1
- package/scripts/create-plugin-list.js +0 -10
- package/scripts/generate-types.js +0 -105
- package/scripts/release-channel.js +0 -18
- package/scripts/release-notes.js +0 -21
- package/scripts/type-utils.js +0 -27
- package/src/cli/build/index.js +0 -53
- package/src/cli/build/plugin.js +0 -469
- package/src/cli/build/utils.js +0 -76
- package/src/cli/build/watching.js +0 -229
- package/src/cli/help/index.js +0 -70
- package/src/cli/index.js +0 -217
- package/src/cli/init/index.js +0 -79
- package/src/cli.js +0 -3
- package/src/corePluginList.js +0 -1
- package/src/corePlugins.js +0 -2877
- package/src/css/LICENSE +0 -25
- package/src/css/preflight.css +0 -379
- package/src/featureFlags.js +0 -68
- package/src/index.js +0 -1
- package/src/lib/cacheInvalidation.js +0 -52
- package/src/lib/collapseAdjacentRules.js +0 -58
- package/src/lib/collapseDuplicateDeclarations.js +0 -93
- package/src/lib/content.js +0 -240
- package/src/lib/defaultExtractor.js +0 -217
- package/src/lib/detectNesting.js +0 -47
- package/src/lib/evaluateTailwindFunctions.js +0 -272
- package/src/lib/expandApplyAtRules.js +0 -613
- package/src/lib/expandTailwindAtRules.js +0 -319
- package/src/lib/findAtConfigPath.js +0 -48
- package/src/lib/generateRules.js +0 -930
- package/src/lib/getModuleDependencies.js +0 -79
- package/src/lib/handleImportAtRules.js +0 -34
- package/src/lib/load-config.ts +0 -31
- package/src/lib/normalizeTailwindDirectives.js +0 -57
- package/src/lib/offsets.js +0 -373
- package/src/lib/partitionApplyAtRules.js +0 -52
- package/src/lib/regex.js +0 -74
- package/src/lib/remap-bitfield.js +0 -82
- package/src/lib/resolveDefaultsAtRules.js +0 -163
- package/src/lib/setupContextUtils.js +0 -1331
- package/src/lib/setupTrackingContext.js +0 -169
- package/src/lib/sharedState.js +0 -57
- package/src/lib/substituteScreenAtRules.js +0 -19
- package/src/plugin.js +0 -133
- package/src/postcss-plugins/nesting/README.md +0 -42
- package/src/postcss-plugins/nesting/index.js +0 -13
- package/src/postcss-plugins/nesting/plugin.js +0 -80
- package/src/processTailwindFeatures.js +0 -59
- package/src/public/colors.js +0 -322
- package/src/public/create-plugin.js +0 -2
- package/src/public/default-config.js +0 -4
- package/src/public/default-theme.js +0 -4
- package/src/public/load-config.js +0 -2
- package/src/public/resolve-config.js +0 -7
- package/src/util/applyImportantSelector.js +0 -27
- package/src/util/bigSign.js +0 -3
- package/src/util/buildMediaQuery.js +0 -22
- package/src/util/cloneDeep.js +0 -11
- package/src/util/cloneNodes.js +0 -28
- package/src/util/color.js +0 -88
- package/src/util/colorNames.js +0 -150
- package/src/util/configurePlugins.js +0 -23
- package/src/util/createPlugin.js +0 -27
- package/src/util/createUtilityPlugin.js +0 -37
- package/src/util/dataTypes.js +0 -340
- package/src/util/defaults.js +0 -17
- package/src/util/escapeClassName.js +0 -8
- package/src/util/escapeCommas.js +0 -3
- package/src/util/flattenColorPalette.js +0 -13
- package/src/util/formatVariantSelector.js +0 -317
- package/src/util/getAllConfigs.js +0 -38
- package/src/util/hashConfig.js +0 -5
- package/src/util/isKeyframeRule.js +0 -3
- package/src/util/isPlainObject.js +0 -8
- package/src/util/isSyntacticallyValidPropertyValue.js +0 -61
- package/src/util/log.js +0 -53
- package/src/util/nameClass.js +0 -30
- package/src/util/negateValue.js +0 -24
- package/src/util/normalizeConfig.js +0 -328
- package/src/util/normalizeScreens.js +0 -140
- package/src/util/parseAnimationValue.js +0 -68
- package/src/util/parseBoxShadowValue.js +0 -72
- package/src/util/parseDependency.js +0 -44
- package/src/util/parseGlob.js +0 -24
- package/src/util/parseObjectStyles.js +0 -19
- package/src/util/pluginUtils.js +0 -287
- package/src/util/prefixSelector.js +0 -33
- package/src/util/pseudoElements.js +0 -167
- package/src/util/removeAlphaVariables.js +0 -24
- package/src/util/resolveConfig.js +0 -277
- package/src/util/resolveConfigPath.js +0 -66
- package/src/util/responsive.js +0 -10
- package/src/util/splitAtTopLevelOnly.js +0 -52
- package/src/util/tap.js +0 -4
- package/src/util/toColorValue.js +0 -3
- package/src/util/toPath.js +0 -26
- package/src/util/transformThemeValue.js +0 -62
- package/src/util/validateConfig.js +0 -36
- package/src/util/validateFormalSyntax.js +0 -34
- package/src/util/withAlphaVariable.js +0 -49
- package/src/value-parser/LICENSE +0 -22
- package/src/value-parser/README.md +0 -3
- package/src/value-parser/index.d.ts +0 -177
- package/src/value-parser/index.js +0 -28
- package/src/value-parser/parse.js +0 -303
- package/src/value-parser/stringify.js +0 -41
- package/src/value-parser/unit.js +0 -118
- package/src/value-parser/walk.js +0 -18
- package/stubs/.gitignore +0 -1
- package/stubs/.prettierrc.json +0 -6
- package/stubs/config.full.js +0 -1002
- package/stubs/config.simple.js +0 -7
- package/stubs/postcss.config.cjs +0 -5
- package/stubs/postcss.config.js +0 -5
- package/stubs/tailwind.config.cjs +0 -2
- package/stubs/tailwind.config.js +0 -2
- package/stubs/tailwind.config.ts +0 -3
- package/tailwind.css +0 -5
- package/types/config.d.ts +0 -369
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +0 -298
- package/types/generated/corePluginList.d.ts +0 -1
- package/types/generated/default-theme.d.ts +0 -378
- package/types/index.d.ts +0 -7
- package/variants.css +0 -1
|
@@ -1,105 +0,0 @@
|
|
|
1
|
-
import prettier from 'prettier'
|
|
2
|
-
import { corePlugins } from '../src/corePlugins'
|
|
3
|
-
import colors from '../src/public/colors'
|
|
4
|
-
import defaultTheme from '../src/public/default-theme'
|
|
5
|
-
import fs from 'fs'
|
|
6
|
-
import path from 'path'
|
|
7
|
-
import * as types from './type-utils'
|
|
8
|
-
|
|
9
|
-
fs.writeFileSync(
|
|
10
|
-
path.join(process.cwd(), 'types', 'generated', 'corePluginList.d.ts'),
|
|
11
|
-
`export type CorePluginList = ${Object.keys(corePlugins)
|
|
12
|
-
.map((p) => `'${p}'`)
|
|
13
|
-
.join(' | ')}`
|
|
14
|
-
)
|
|
15
|
-
|
|
16
|
-
let colorsWithoutDeprecatedColors = Object.fromEntries(
|
|
17
|
-
Object.entries(Object.getOwnPropertyDescriptors(colors))
|
|
18
|
-
.filter(([_, { value }]) => {
|
|
19
|
-
return typeof value !== 'undefined'
|
|
20
|
-
})
|
|
21
|
-
.map(([name, definition]) => [name, definition.value])
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
let deprecatedColors = Object.entries(Object.getOwnPropertyDescriptors(colors))
|
|
25
|
-
.filter(([_, { value }]) => {
|
|
26
|
-
return typeof value === 'undefined'
|
|
27
|
-
})
|
|
28
|
-
.map(([name, definition]) => {
|
|
29
|
-
let warn = console.warn
|
|
30
|
-
let messages = []
|
|
31
|
-
console.warn = (...args) => messages.push(args.pop())
|
|
32
|
-
definition.get()
|
|
33
|
-
console.warn = warn
|
|
34
|
-
let message = messages.join(' ').trim()
|
|
35
|
-
let newColor = message.match(/renamed to `(.*)`/)[1]
|
|
36
|
-
return `/** @deprecated ${message} */${name}: DefaultColors['${newColor}'],`
|
|
37
|
-
})
|
|
38
|
-
.join('\n')
|
|
39
|
-
|
|
40
|
-
fs.writeFileSync(
|
|
41
|
-
path.join(process.cwd(), 'types', 'generated', 'colors.d.ts'),
|
|
42
|
-
prettier.format(
|
|
43
|
-
`export interface DefaultColors { ${JSON.stringify(colorsWithoutDeprecatedColors).slice(
|
|
44
|
-
1,
|
|
45
|
-
-1
|
|
46
|
-
)}\n${deprecatedColors}\n}`,
|
|
47
|
-
{
|
|
48
|
-
semi: false,
|
|
49
|
-
singleQuote: true,
|
|
50
|
-
printWidth: 100,
|
|
51
|
-
parser: 'typescript',
|
|
52
|
-
}
|
|
53
|
-
)
|
|
54
|
-
)
|
|
55
|
-
|
|
56
|
-
const defaultThemeTypes = Object.entries(defaultTheme)
|
|
57
|
-
.map(([name, value]) => {
|
|
58
|
-
// Special cases for slightly more accurate types
|
|
59
|
-
if (name === 'keyframes') {
|
|
60
|
-
return [name, `Record<${types.forKeys(value)}, Record<string, CSSDeclarationList>>`]
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (name === 'fontSize') {
|
|
64
|
-
return [name, `Record<${types.forKeys(value)}, [string, { lineHeight: string }]>`]
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
// General cases
|
|
68
|
-
if (typeof value === 'string') {
|
|
69
|
-
return [name, `string`]
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
if (typeof value === 'function') {
|
|
73
|
-
return [name, null]
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (typeof value === 'object') {
|
|
77
|
-
if (Object.keys(value).length === 0) {
|
|
78
|
-
return [name, null]
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
return [name, types.forValue(value)]
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
return [name, `unknown`]
|
|
85
|
-
})
|
|
86
|
-
.filter(([, type]) => type !== null)
|
|
87
|
-
.map(([name, type]) => `${name}: ${type}`)
|
|
88
|
-
.join('\n')
|
|
89
|
-
|
|
90
|
-
fs.writeFileSync(
|
|
91
|
-
path.join(process.cwd(), 'types', 'generated', 'default-theme.d.ts'),
|
|
92
|
-
prettier.format(
|
|
93
|
-
`
|
|
94
|
-
import { Config } from '../../types'
|
|
95
|
-
type CSSDeclarationList = Record<string, string>
|
|
96
|
-
export type DefaultTheme = Config['theme'] & { ${defaultThemeTypes} }
|
|
97
|
-
`,
|
|
98
|
-
{
|
|
99
|
-
semi: false,
|
|
100
|
-
singleQuote: true,
|
|
101
|
-
printWidth: 100,
|
|
102
|
-
parser: 'typescript',
|
|
103
|
-
}
|
|
104
|
-
)
|
|
105
|
-
)
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
// Given a version, figure out what the release channel is so that we can publish to the correct
|
|
2
|
-
// channel on npm.
|
|
3
|
-
//
|
|
4
|
-
// E.g.:
|
|
5
|
-
//
|
|
6
|
-
// 1.2.3 -> latest (default)
|
|
7
|
-
// 0.0.0-insiders.ffaa88 -> insiders
|
|
8
|
-
// 4.1.0-alpha.4 -> alpha
|
|
9
|
-
|
|
10
|
-
let version =
|
|
11
|
-
process.argv[2] || process.env.npm_package_version || require('../package.json').version
|
|
12
|
-
|
|
13
|
-
let match = /\d+\.\d+\.\d+-(.*)\.\d+/g.exec(version)
|
|
14
|
-
if (match) {
|
|
15
|
-
console.log(match[1])
|
|
16
|
-
} else {
|
|
17
|
-
console.log('latest')
|
|
18
|
-
}
|
package/scripts/release-notes.js
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
// Given a version, figure out what the release notes are so that we can use this to pre-fill the
|
|
2
|
-
// release notes on a GitHub release for the current version.
|
|
3
|
-
|
|
4
|
-
let path = require('path')
|
|
5
|
-
let fs = require('fs')
|
|
6
|
-
|
|
7
|
-
let version =
|
|
8
|
-
process.argv[2] || process.env.npm_package_version || require('../package.json').version
|
|
9
|
-
|
|
10
|
-
let changelog = fs.readFileSync(path.resolve(__dirname, '..', 'CHANGELOG.md'), 'utf8')
|
|
11
|
-
let match = new RegExp(
|
|
12
|
-
`## \\[${version}\\] - (.*)\\n\\n([\\s\\S]*?)\\n(?:(?:##\\s)|(?:\\[))`,
|
|
13
|
-
'g'
|
|
14
|
-
).exec(changelog)
|
|
15
|
-
|
|
16
|
-
if (match) {
|
|
17
|
-
let [, , notes] = match
|
|
18
|
-
console.log(notes.trim())
|
|
19
|
-
} else {
|
|
20
|
-
console.log(`Placeholder release notes for version: v${version}`)
|
|
21
|
-
}
|
package/scripts/type-utils.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
export function union(types) {
|
|
2
|
-
return [...new Set(types)].join(' | ')
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
export function unionValues(values) {
|
|
6
|
-
return union(values.map(forValue))
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export function forKeys(value) {
|
|
10
|
-
return union(Object.keys(value).map((key) => `'${key}'`))
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function forValue(value) {
|
|
14
|
-
if (Array.isArray(value)) {
|
|
15
|
-
return `(${unionValues(value)})[]`
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (typeof value === 'object') {
|
|
19
|
-
return `Record<${forKeys(value)}, ${unionValues(Object.values(value))}>`
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
if (typeof value === 'string') {
|
|
23
|
-
return `string`
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
return `any`
|
|
27
|
-
}
|
package/src/cli/build/index.js
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import fs from 'fs'
|
|
4
|
-
import path from 'path'
|
|
5
|
-
import { resolveDefaultConfigPath } from '../../util/resolveConfigPath.js'
|
|
6
|
-
import { createProcessor } from './plugin.js'
|
|
7
|
-
|
|
8
|
-
export async function build(args) {
|
|
9
|
-
let input = args['--input']
|
|
10
|
-
let shouldWatch = args['--watch']
|
|
11
|
-
|
|
12
|
-
// TODO: Deprecate this in future versions
|
|
13
|
-
if (!input && args['_'][1]) {
|
|
14
|
-
console.error('[deprecation] Running tailwindcss without -i, please provide an input file.')
|
|
15
|
-
input = args['--input'] = args['_'][1]
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
if (input && input !== '-' && !fs.existsSync((input = path.resolve(input)))) {
|
|
19
|
-
console.error(`Specified input file ${args['--input']} does not exist.`)
|
|
20
|
-
process.exit(9)
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (args['--config'] && !fs.existsSync((args['--config'] = path.resolve(args['--config'])))) {
|
|
24
|
-
console.error(`Specified config file ${args['--config']} does not exist.`)
|
|
25
|
-
process.exit(9)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
if (args['--no-autoprefixer']) {
|
|
29
|
-
console.error('[deprecation] The --no-autoprefixer flag is deprecated and has no effect.')
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
// TODO: Reference the @config path here if exists
|
|
33
|
-
let configPath = args['--config'] ? args['--config'] : resolveDefaultConfigPath()
|
|
34
|
-
|
|
35
|
-
let processor = await createProcessor(args, configPath)
|
|
36
|
-
|
|
37
|
-
if (shouldWatch) {
|
|
38
|
-
// Abort the watcher if stdin is closed to avoid zombie processes
|
|
39
|
-
// You can disable this behavior with --watch=always
|
|
40
|
-
if (args['--watch'] !== 'always') {
|
|
41
|
-
process.stdin.on('end', () => process.exit(0))
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
process.stdin.resume()
|
|
45
|
-
|
|
46
|
-
await processor.watch()
|
|
47
|
-
} else {
|
|
48
|
-
await processor.build().catch((e) => {
|
|
49
|
-
console.error(e)
|
|
50
|
-
process.exit(1)
|
|
51
|
-
})
|
|
52
|
-
}
|
|
53
|
-
}
|
package/src/cli/build/plugin.js
DELETED
|
@@ -1,469 +0,0 @@
|
|
|
1
|
-
// @ts-check
|
|
2
|
-
|
|
3
|
-
import pkg from '../../../package.json'
|
|
4
|
-
import path from 'path'
|
|
5
|
-
import fs from 'fs'
|
|
6
|
-
import postcss from 'postcss'
|
|
7
|
-
import postcssrc from 'postcss-load-config'
|
|
8
|
-
import browserslist from 'browserslist'
|
|
9
|
-
import lightning, { Features } from 'lightningcss'
|
|
10
|
-
import { lilconfig } from 'lilconfig'
|
|
11
|
-
import loadPlugins from 'postcss-load-config/src/plugins' // Little bit scary, looking at private/internal API
|
|
12
|
-
import loadOptions from 'postcss-load-config/src/options' // Little bit scary, looking at private/internal API
|
|
13
|
-
|
|
14
|
-
import tailwind from '../../processTailwindFeatures'
|
|
15
|
-
import { formatNodes, drainStdin, outputFile } from './utils'
|
|
16
|
-
import { env } from '../../lib/sharedState'
|
|
17
|
-
import resolveConfig from '../../../resolveConfig.js'
|
|
18
|
-
import { parseCandidateFiles } from '../../lib/content.js'
|
|
19
|
-
import { createWatcher } from './watching.js'
|
|
20
|
-
import fastGlob from 'fast-glob'
|
|
21
|
-
import { findAtConfigPath } from '../../lib/findAtConfigPath.js'
|
|
22
|
-
import log from '../../util/log'
|
|
23
|
-
import { loadConfig } from '../../lib/load-config'
|
|
24
|
-
import getModuleDependencies from '../../lib/getModuleDependencies'
|
|
25
|
-
import { validateConfig } from '../../util/validateConfig'
|
|
26
|
-
import { handleImportAtRules } from '../../lib/handleImportAtRules'
|
|
27
|
-
import { flagEnabled } from '../../featureFlags'
|
|
28
|
-
|
|
29
|
-
function license() {
|
|
30
|
-
return `/* ! tailwindcss v${pkg.version} | MIT License | https://tailwindcss.com */\n`
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
async function lightningcss(result, { map = true, minify = true } = {}) {
|
|
34
|
-
try {
|
|
35
|
-
let resolvedBrowsersListConfig = browserslist.findConfig(
|
|
36
|
-
result.opts.from ?? process.cwd()
|
|
37
|
-
)?.defaults
|
|
38
|
-
let defaultBrowsersListConfig = pkg.browserslist
|
|
39
|
-
let browsersListConfig = resolvedBrowsersListConfig ?? defaultBrowsersListConfig
|
|
40
|
-
|
|
41
|
-
let transformed = lightning.transform({
|
|
42
|
-
filename: result.opts.from || 'input.css',
|
|
43
|
-
code: Buffer.from(result.css, 'utf-8'),
|
|
44
|
-
minify,
|
|
45
|
-
sourceMap: result.map === undefined ? map : !!result.map,
|
|
46
|
-
inputSourceMap: result.map ? result.map.toString() : undefined,
|
|
47
|
-
targets: lightning.browserslistToTargets(browserslist(browsersListConfig)),
|
|
48
|
-
drafts: {
|
|
49
|
-
nesting: true,
|
|
50
|
-
},
|
|
51
|
-
include: Features.Nesting,
|
|
52
|
-
exclude: Features.LogicalProperties,
|
|
53
|
-
})
|
|
54
|
-
|
|
55
|
-
return Object.assign(result, {
|
|
56
|
-
css: transformed.code.toString('utf8'),
|
|
57
|
-
map: result.map
|
|
58
|
-
? Object.assign(result.map, {
|
|
59
|
-
toString() {
|
|
60
|
-
return transformed.map?.toString()
|
|
61
|
-
},
|
|
62
|
-
})
|
|
63
|
-
: result.map,
|
|
64
|
-
})
|
|
65
|
-
} catch (err) {
|
|
66
|
-
console.error('Unable to use Lightning CSS. Using raw version instead.')
|
|
67
|
-
console.error(err)
|
|
68
|
-
|
|
69
|
-
return result
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
/**
|
|
74
|
-
*
|
|
75
|
-
* @param {string} [customPostCssPath ]
|
|
76
|
-
* @returns
|
|
77
|
-
*/
|
|
78
|
-
async function loadPostCssPlugins(customPostCssPath) {
|
|
79
|
-
let config = customPostCssPath
|
|
80
|
-
? await (async () => {
|
|
81
|
-
let file = path.resolve(customPostCssPath)
|
|
82
|
-
|
|
83
|
-
// Implementation, see: https://unpkg.com/browse/postcss-load-config@3.1.0/src/index.js
|
|
84
|
-
// @ts-ignore
|
|
85
|
-
let { config = {} } = await lilconfig('postcss').load(file)
|
|
86
|
-
if (typeof config === 'function') {
|
|
87
|
-
config = config()
|
|
88
|
-
} else {
|
|
89
|
-
config = Object.assign({}, config)
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
if (!config.plugins) {
|
|
93
|
-
config.plugins = []
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return {
|
|
97
|
-
file,
|
|
98
|
-
plugins: loadPlugins(config, file),
|
|
99
|
-
options: loadOptions(config, file),
|
|
100
|
-
}
|
|
101
|
-
})()
|
|
102
|
-
: await postcssrc()
|
|
103
|
-
|
|
104
|
-
let configPlugins = config.plugins
|
|
105
|
-
|
|
106
|
-
let configPluginTailwindIdx = configPlugins.findIndex((plugin) => {
|
|
107
|
-
if (typeof plugin === 'function' && plugin.name === 'tailwindcss') {
|
|
108
|
-
return true
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
if (typeof plugin === 'object' && plugin !== null && plugin.postcssPlugin === 'tailwindcss') {
|
|
112
|
-
return true
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
return false
|
|
116
|
-
})
|
|
117
|
-
|
|
118
|
-
let beforePlugins =
|
|
119
|
-
configPluginTailwindIdx === -1 ? [] : configPlugins.slice(0, configPluginTailwindIdx)
|
|
120
|
-
let afterPlugins =
|
|
121
|
-
configPluginTailwindIdx === -1
|
|
122
|
-
? configPlugins
|
|
123
|
-
: configPlugins.slice(configPluginTailwindIdx + 1)
|
|
124
|
-
|
|
125
|
-
return [beforePlugins, afterPlugins, config.options]
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
let state = {
|
|
129
|
-
/** @type {any} */
|
|
130
|
-
context: null,
|
|
131
|
-
|
|
132
|
-
/** @type {ReturnType<typeof createWatcher> | null} */
|
|
133
|
-
watcher: null,
|
|
134
|
-
|
|
135
|
-
/** @type {{content: string, extension: string}[]} */
|
|
136
|
-
changedContent: [],
|
|
137
|
-
|
|
138
|
-
/** @type {{config: import('../../../types').Config, dependencies: Set<string>, dispose: Function } | null} */
|
|
139
|
-
configBag: null,
|
|
140
|
-
|
|
141
|
-
contextDependencies: new Set(),
|
|
142
|
-
|
|
143
|
-
/** @type {import('../../lib/content.js').ContentPath[]} */
|
|
144
|
-
contentPaths: [],
|
|
145
|
-
|
|
146
|
-
refreshContentPaths() {
|
|
147
|
-
this.contentPaths = parseCandidateFiles(this.context, this.context?.tailwindConfig)
|
|
148
|
-
},
|
|
149
|
-
|
|
150
|
-
get config() {
|
|
151
|
-
return this.context.tailwindConfig
|
|
152
|
-
},
|
|
153
|
-
|
|
154
|
-
get contentPatterns() {
|
|
155
|
-
return {
|
|
156
|
-
all: this.contentPaths.map((contentPath) => contentPath.pattern),
|
|
157
|
-
dynamic: this.contentPaths
|
|
158
|
-
.filter((contentPath) => contentPath.glob !== undefined)
|
|
159
|
-
.map((contentPath) => contentPath.pattern),
|
|
160
|
-
}
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
loadConfig(configPath, content) {
|
|
164
|
-
if (this.watcher && configPath) {
|
|
165
|
-
this.refreshConfigDependencies()
|
|
166
|
-
}
|
|
167
|
-
|
|
168
|
-
let config = loadConfig(configPath)
|
|
169
|
-
let dependencies = getModuleDependencies(configPath)
|
|
170
|
-
this.configBag = {
|
|
171
|
-
config,
|
|
172
|
-
dependencies,
|
|
173
|
-
dispose() {
|
|
174
|
-
for (let file of dependencies) {
|
|
175
|
-
delete require.cache[require.resolve(file)]
|
|
176
|
-
}
|
|
177
|
-
},
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
this.configBag.config = validateConfig(resolveConfig(this.configBag.config))
|
|
181
|
-
|
|
182
|
-
// Override content files if `--content` has been passed explicitly
|
|
183
|
-
if (content?.length > 0) {
|
|
184
|
-
this.configBag.config.content.files = content
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return this.configBag.config
|
|
188
|
-
},
|
|
189
|
-
|
|
190
|
-
refreshConfigDependencies() {
|
|
191
|
-
env.DEBUG && console.time('Module dependencies')
|
|
192
|
-
this.configBag?.dispose()
|
|
193
|
-
env.DEBUG && console.timeEnd('Module dependencies')
|
|
194
|
-
},
|
|
195
|
-
|
|
196
|
-
readContentPaths() {
|
|
197
|
-
let content = []
|
|
198
|
-
|
|
199
|
-
// Resolve globs from the content config
|
|
200
|
-
// TODO: When we make the postcss plugin async-capable this can become async
|
|
201
|
-
let files = fastGlob.sync(this.contentPatterns.all)
|
|
202
|
-
|
|
203
|
-
for (let file of files) {
|
|
204
|
-
if (flagEnabled(this.config, 'oxideParser')) {
|
|
205
|
-
content.push({
|
|
206
|
-
file,
|
|
207
|
-
extension: path.extname(file).slice(1),
|
|
208
|
-
})
|
|
209
|
-
} else {
|
|
210
|
-
content.push({
|
|
211
|
-
content: fs.readFileSync(path.resolve(file), 'utf8'),
|
|
212
|
-
extension: path.extname(file).slice(1),
|
|
213
|
-
})
|
|
214
|
-
}
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// Resolve raw content in the tailwind config
|
|
218
|
-
let rawContent = this.config.content.files.filter((file) => {
|
|
219
|
-
return file !== null && typeof file === 'object'
|
|
220
|
-
})
|
|
221
|
-
|
|
222
|
-
for (let { raw: htmlContent, extension = 'html' } of rawContent) {
|
|
223
|
-
content.push({ content: htmlContent, extension })
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
return content
|
|
227
|
-
},
|
|
228
|
-
|
|
229
|
-
getContext({ createContext, cliConfigPath, root, result, content }) {
|
|
230
|
-
if (this.context) {
|
|
231
|
-
this.context.changedContent = this.changedContent.splice(0)
|
|
232
|
-
|
|
233
|
-
return this.context
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
env.DEBUG && console.time('Searching for config')
|
|
237
|
-
let configPath = findAtConfigPath(root, result) ?? cliConfigPath
|
|
238
|
-
env.DEBUG && console.timeEnd('Searching for config')
|
|
239
|
-
|
|
240
|
-
env.DEBUG && console.time('Loading config')
|
|
241
|
-
let config = this.loadConfig(configPath, content)
|
|
242
|
-
env.DEBUG && console.timeEnd('Loading config')
|
|
243
|
-
|
|
244
|
-
env.DEBUG && console.time('Creating context')
|
|
245
|
-
this.context = createContext(config, [])
|
|
246
|
-
Object.assign(this.context, {
|
|
247
|
-
userConfigPath: configPath,
|
|
248
|
-
})
|
|
249
|
-
env.DEBUG && console.timeEnd('Creating context')
|
|
250
|
-
|
|
251
|
-
env.DEBUG && console.time('Resolving content paths')
|
|
252
|
-
this.refreshContentPaths()
|
|
253
|
-
env.DEBUG && console.timeEnd('Resolving content paths')
|
|
254
|
-
|
|
255
|
-
if (this.watcher) {
|
|
256
|
-
env.DEBUG && console.time('Watch new files')
|
|
257
|
-
this.watcher.refreshWatchedFiles()
|
|
258
|
-
env.DEBUG && console.timeEnd('Watch new files')
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
for (let file of this.readContentPaths()) {
|
|
262
|
-
this.context.changedContent.push(file)
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
return this.context
|
|
266
|
-
},
|
|
267
|
-
}
|
|
268
|
-
|
|
269
|
-
export async function createProcessor(args, cliConfigPath) {
|
|
270
|
-
let input = args['--input']
|
|
271
|
-
let output = args['--output']
|
|
272
|
-
let includePostCss = args['--postcss']
|
|
273
|
-
let customPostCssPath = typeof args['--postcss'] === 'string' ? args['--postcss'] : undefined
|
|
274
|
-
|
|
275
|
-
let [beforePlugins, afterPlugins, postcssOptions] = includePostCss
|
|
276
|
-
? await loadPostCssPlugins(customPostCssPath)
|
|
277
|
-
: [[], [], {}]
|
|
278
|
-
|
|
279
|
-
beforePlugins.unshift(...handleImportAtRules())
|
|
280
|
-
|
|
281
|
-
if (args['--purge']) {
|
|
282
|
-
log.warn('purge-flag-deprecated', [
|
|
283
|
-
'The `--purge` flag has been deprecated.',
|
|
284
|
-
'Please use `--content` instead.',
|
|
285
|
-
])
|
|
286
|
-
|
|
287
|
-
if (!args['--content']) {
|
|
288
|
-
args['--content'] = args['--purge']
|
|
289
|
-
}
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
let content = args['--content']?.split(/(?<!{[^}]+),/) ?? []
|
|
293
|
-
|
|
294
|
-
let tailwindPlugin = () => {
|
|
295
|
-
return {
|
|
296
|
-
postcssPlugin: 'tailwindcss',
|
|
297
|
-
async Once(root, { result }) {
|
|
298
|
-
env.DEBUG && console.time('Compiling CSS')
|
|
299
|
-
await tailwind(({ createContext }) => {
|
|
300
|
-
console.error()
|
|
301
|
-
console.error('Rebuilding...')
|
|
302
|
-
|
|
303
|
-
return () => {
|
|
304
|
-
return state.getContext({
|
|
305
|
-
createContext,
|
|
306
|
-
cliConfigPath,
|
|
307
|
-
root,
|
|
308
|
-
result,
|
|
309
|
-
content,
|
|
310
|
-
})
|
|
311
|
-
}
|
|
312
|
-
})(root, result)
|
|
313
|
-
env.DEBUG && console.timeEnd('Compiling CSS')
|
|
314
|
-
},
|
|
315
|
-
}
|
|
316
|
-
}
|
|
317
|
-
|
|
318
|
-
tailwindPlugin.postcss = true
|
|
319
|
-
|
|
320
|
-
let plugins = [
|
|
321
|
-
...beforePlugins,
|
|
322
|
-
tailwindPlugin,
|
|
323
|
-
!args['--minify'] && formatNodes,
|
|
324
|
-
...afterPlugins,
|
|
325
|
-
].filter(Boolean)
|
|
326
|
-
|
|
327
|
-
/** @type {import('postcss').Processor} */
|
|
328
|
-
// @ts-ignore
|
|
329
|
-
let processor = postcss(plugins)
|
|
330
|
-
|
|
331
|
-
async function readInput() {
|
|
332
|
-
// Piping in data, let's drain the stdin
|
|
333
|
-
if (input === '-') {
|
|
334
|
-
return drainStdin()
|
|
335
|
-
}
|
|
336
|
-
|
|
337
|
-
// Input file has been provided
|
|
338
|
-
if (input) {
|
|
339
|
-
return fs.promises.readFile(path.resolve(input), 'utf8')
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
// No input file provided, fallback to default atrules
|
|
343
|
-
return '@tailwind base; @tailwind components; @tailwind utilities'
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
async function build() {
|
|
347
|
-
let start = process.hrtime.bigint()
|
|
348
|
-
let options = {
|
|
349
|
-
...postcssOptions,
|
|
350
|
-
from: input,
|
|
351
|
-
to: output,
|
|
352
|
-
}
|
|
353
|
-
|
|
354
|
-
return readInput()
|
|
355
|
-
.then((css) => processor.process(css, options))
|
|
356
|
-
.then((result) =>
|
|
357
|
-
lightningcss(result, {
|
|
358
|
-
...options,
|
|
359
|
-
minify: !!args['--minify'],
|
|
360
|
-
})
|
|
361
|
-
)
|
|
362
|
-
.then((result) => {
|
|
363
|
-
if (!state.watcher) {
|
|
364
|
-
return result
|
|
365
|
-
}
|
|
366
|
-
|
|
367
|
-
env.DEBUG && console.time('Recording PostCSS dependencies')
|
|
368
|
-
for (let message of result.messages) {
|
|
369
|
-
if (message.type === 'dependency') {
|
|
370
|
-
state.contextDependencies.add(message.file)
|
|
371
|
-
}
|
|
372
|
-
}
|
|
373
|
-
env.DEBUG && console.timeEnd('Recording PostCSS dependencies')
|
|
374
|
-
|
|
375
|
-
// TODO: This needs to be in a different spot
|
|
376
|
-
env.DEBUG && console.time('Watch new files')
|
|
377
|
-
state.watcher.refreshWatchedFiles()
|
|
378
|
-
env.DEBUG && console.timeEnd('Watch new files')
|
|
379
|
-
|
|
380
|
-
return result
|
|
381
|
-
})
|
|
382
|
-
.then((result) => {
|
|
383
|
-
if (!output) {
|
|
384
|
-
process.stdout.write(license() + result.css)
|
|
385
|
-
return
|
|
386
|
-
}
|
|
387
|
-
|
|
388
|
-
return Promise.all([
|
|
389
|
-
outputFile(result.opts.to, license() + result.css),
|
|
390
|
-
result.map && outputFile(result.opts.to + '.map', result.map.toString()),
|
|
391
|
-
])
|
|
392
|
-
})
|
|
393
|
-
.then(() => {
|
|
394
|
-
let end = process.hrtime.bigint()
|
|
395
|
-
console.error()
|
|
396
|
-
console.error('Done in', (end - start) / BigInt(1e6) + 'ms.')
|
|
397
|
-
})
|
|
398
|
-
.then(
|
|
399
|
-
() => {},
|
|
400
|
-
(err) => {
|
|
401
|
-
// TODO: If an initial build fails we can't easily pick up any PostCSS dependencies
|
|
402
|
-
// that were collected before the error occurred
|
|
403
|
-
// The result is not stored on the error so we have to store it externally
|
|
404
|
-
// and pull the messages off of it here somehow
|
|
405
|
-
|
|
406
|
-
// This results in a less than ideal DX because the watcher will not pick up
|
|
407
|
-
// changes to imported CSS if one of them caused an error during the initial build
|
|
408
|
-
// If you fix it and then save the main CSS file so there's no error
|
|
409
|
-
// The watcher will start watching the imported CSS files and will be
|
|
410
|
-
// resilient to future errors.
|
|
411
|
-
|
|
412
|
-
if (state.watcher) {
|
|
413
|
-
console.error(err)
|
|
414
|
-
} else {
|
|
415
|
-
return Promise.reject(err)
|
|
416
|
-
}
|
|
417
|
-
}
|
|
418
|
-
)
|
|
419
|
-
}
|
|
420
|
-
|
|
421
|
-
/**
|
|
422
|
-
* @param {{file: string, content(): Promise<string>, extension: string}[]} changes
|
|
423
|
-
*/
|
|
424
|
-
async function parseChanges(changes) {
|
|
425
|
-
return Promise.all(
|
|
426
|
-
changes.map(async (change) => ({
|
|
427
|
-
content: await change.content(),
|
|
428
|
-
extension: change.extension,
|
|
429
|
-
}))
|
|
430
|
-
)
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
if (input !== undefined && input !== '-') {
|
|
434
|
-
state.contextDependencies.add(path.resolve(input))
|
|
435
|
-
}
|
|
436
|
-
|
|
437
|
-
return {
|
|
438
|
-
build,
|
|
439
|
-
watch: async () => {
|
|
440
|
-
state.watcher = createWatcher(args, {
|
|
441
|
-
state,
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* @param {{file: string, content(): Promise<string>, extension: string}[]} changes
|
|
445
|
-
*/
|
|
446
|
-
async rebuild(changes) {
|
|
447
|
-
let needsNewContext = changes.some((change) => {
|
|
448
|
-
return (
|
|
449
|
-
state.configBag?.dependencies.has(change.file) ||
|
|
450
|
-
state.contextDependencies.has(change.file)
|
|
451
|
-
)
|
|
452
|
-
})
|
|
453
|
-
|
|
454
|
-
if (needsNewContext) {
|
|
455
|
-
state.context = null
|
|
456
|
-
} else {
|
|
457
|
-
for (let change of await parseChanges(changes)) {
|
|
458
|
-
state.changedContent.push(change)
|
|
459
|
-
}
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
return build()
|
|
463
|
-
},
|
|
464
|
-
})
|
|
465
|
-
|
|
466
|
-
await build()
|
|
467
|
-
},
|
|
468
|
-
}
|
|
469
|
-
}
|