tailwindcss 0.0.0-insiders.6df8cd9 → 0.0.0-insiders.6f53bde
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 +96 -13
- package/README.md +6 -5
- package/lib/cli/build/index.js +5 -1
- package/lib/cli/build/plugin.js +57 -12
- package/lib/cli/build/watching.js +77 -12
- package/lib/cli.js +20 -10
- package/lib/corePlugins.js +310 -92
- package/lib/css/preflight.css +2 -0
- package/lib/featureFlags.js +5 -4
- package/lib/index.js +1 -1
- package/lib/lib/content.js +17 -2
- package/lib/lib/defaultExtractor.js +17 -12
- package/lib/lib/detectNesting.js +2 -2
- package/lib/lib/evaluateTailwindFunctions.js +1 -1
- package/lib/lib/expandApplyAtRules.js +36 -17
- package/lib/lib/expandTailwindAtRules.js +2 -2
- package/lib/lib/findAtConfigPath.js +4 -4
- package/lib/lib/generateRules.js +136 -51
- package/lib/lib/normalizeTailwindDirectives.js +1 -1
- package/lib/lib/offsets.js +21 -3
- package/lib/lib/regex.js +1 -1
- package/lib/lib/setupContextUtils.js +276 -61
- package/lib/lib/sharedState.js +2 -0
- package/lib/public/colors.js +1 -1
- package/lib/util/buildMediaQuery.js +6 -3
- package/lib/util/configurePlugins.js +1 -1
- package/lib/util/dataTypes.js +14 -11
- package/lib/util/formatVariantSelector.js +3 -3
- package/lib/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +3 -3
- package/lib/util/nameClass.js +3 -0
- package/lib/util/normalizeConfig.js +16 -2
- package/lib/util/normalizeScreens.js +100 -3
- package/lib/util/parseAnimationValue.js +1 -1
- package/lib/util/parseDependency.js +3 -3
- package/lib/util/parseObjectStyles.js +1 -1
- package/lib/util/pluginUtils.js +99 -11
- package/lib/util/resolveConfig.js +5 -10
- package/lib/util/transformThemeValue.js +1 -1
- package/lib/util/validateConfig.js +1 -1
- package/lib/util/validateFormalSyntax.js +24 -0
- package/package.json +20 -19
- package/peers/index.js +695 -603
- package/plugin.d.ts +3 -3
- package/resolveConfig.d.ts +11 -2
- package/scripts/release-channel.js +18 -0
- package/scripts/release-notes.js +21 -0
- package/src/cli/build/index.js +6 -2
- package/src/cli/build/plugin.js +70 -8
- package/src/cli/build/watching.js +105 -12
- package/src/cli.js +24 -13
- package/src/corePlugins.js +247 -36
- package/src/css/preflight.css +2 -0
- package/src/featureFlags.js +2 -1
- package/src/lib/content.js +18 -4
- package/src/lib/defaultExtractor.js +5 -2
- package/src/lib/expandApplyAtRules.js +35 -15
- package/src/lib/findAtConfigPath.js +4 -6
- package/src/lib/generateRules.js +182 -64
- package/src/lib/offsets.js +33 -2
- package/src/lib/setupContextUtils.js +289 -41
- package/src/lib/sharedState.js +2 -0
- package/src/util/buildMediaQuery.js +5 -3
- package/src/util/dataTypes.js +15 -11
- package/src/util/formatVariantSelector.js +2 -2
- package/src/util/{isValidArbitraryValue.js → isSyntacticallyValidPropertyValue.js} +1 -1
- package/src/util/nameClass.js +4 -0
- package/src/util/normalizeConfig.js +18 -0
- package/src/util/normalizeScreens.js +99 -4
- package/src/util/pluginUtils.js +119 -9
- package/src/util/resolveConfig.js +3 -9
- package/src/util/validateFormalSyntax.js +34 -0
- package/stubs/defaultConfig.stub.js +157 -164
- package/types/config.d.ts +31 -9
- package/types/generated/default-theme.d.ts +87 -76
package/CHANGELOG.md
CHANGED
|
@@ -9,36 +9,114 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
+
- Add `line-height` modifier support to `font-size` utilities ([#9875](https://github.com/tailwindlabs/tailwindcss/pull/9875))
|
|
13
|
+
- Support using variables as arbitrary values without `var(...)` ([#9880](https://github.com/tailwindlabs/tailwindcss/pull/9880), [#9962](https://github.com/tailwindlabs/tailwindcss/pull/9962))
|
|
14
|
+
- Add `--watch=always` option to prevent exit when stdin closes ([#9966](https://github.com/tailwindlabs/tailwindcss/pull/9966))
|
|
15
|
+
|
|
16
|
+
### Fixed
|
|
17
|
+
|
|
18
|
+
- Cleanup unused `variantOrder` ([#9829](https://github.com/tailwindlabs/tailwindcss/pull/9829))
|
|
19
|
+
- Fix `foo-[abc]/[def]` not being handled correctly ([#9866](https://github.com/tailwindlabs/tailwindcss/pull/9866))
|
|
20
|
+
- Add container queries plugin to standalone CLI ([#9865](https://github.com/tailwindlabs/tailwindcss/pull/9865))
|
|
21
|
+
- Support renaming of output files by `PostCSS` plugin. ([#9944](https://github.com/tailwindlabs/tailwindcss/pull/9944))
|
|
22
|
+
- Improve return value of `resolveConfig`, unwrap `ResolvableTo` ([#9972](https://github.com/tailwindlabs/tailwindcss/pull/9972))
|
|
23
|
+
- Clip unbalanced brackets in arbitrary values ([#9973](https://github.com/tailwindlabs/tailwindcss/pull/9973))
|
|
24
|
+
|
|
25
|
+
### Changed
|
|
26
|
+
|
|
27
|
+
- Alphabetize `theme` keys in default config ([#9953](https://github.com/tailwindlabs/tailwindcss/pull/9953))
|
|
28
|
+
|
|
29
|
+
## [3.2.4] - 2022-11-11
|
|
30
|
+
|
|
31
|
+
### Added
|
|
32
|
+
|
|
33
|
+
- Add `blocklist` option to prevent generating unwanted CSS ([#9812](https://github.com/tailwindlabs/tailwindcss/pull/9812))
|
|
34
|
+
|
|
35
|
+
### Fixed
|
|
36
|
+
|
|
37
|
+
- Fix watching of files on Linux when renames are involved ([#9796](https://github.com/tailwindlabs/tailwindcss/pull/9796))
|
|
38
|
+
- Make sure errors are always displayed when watching for changes ([#9810](https://github.com/tailwindlabs/tailwindcss/pull/9810))
|
|
39
|
+
|
|
40
|
+
## [3.2.3] - 2022-11-09
|
|
41
|
+
|
|
42
|
+
### Fixed
|
|
43
|
+
|
|
44
|
+
- Fixed use of `raw` content in the CLI ([#9773](https://github.com/tailwindlabs/tailwindcss/pull/9773))
|
|
45
|
+
- Pick up changes from files that are both context and content deps ([#9787](https://github.com/tailwindlabs/tailwindcss/pull/9787))
|
|
46
|
+
- Sort pseudo-elements ONLY after classes when using variants and `@apply` ([#9765](https://github.com/tailwindlabs/tailwindcss/pull/9765))
|
|
47
|
+
- Support important utilities in the safelist (pattern must include a `!`) ([#9791](https://github.com/tailwindlabs/tailwindcss/pull/9791))
|
|
48
|
+
|
|
49
|
+
## [3.2.2] - 2022-11-04
|
|
50
|
+
|
|
51
|
+
### Fixed
|
|
52
|
+
|
|
53
|
+
- Escape special characters in resolved content base paths ([#9650](https://github.com/tailwindlabs/tailwindcss/pull/9650))
|
|
54
|
+
- Don't reuse container for array returning variant functions ([#9644](https://github.com/tailwindlabs/tailwindcss/pull/9644))
|
|
55
|
+
- Exclude non-relevant selectors when generating rules with the important modifier ([#9677](https://github.com/tailwindlabs/tailwindcss/issues/9677))
|
|
56
|
+
- Fix merging of arrays during config resolution ([#9706](https://github.com/tailwindlabs/tailwindcss/issues/9706))
|
|
57
|
+
- Ensure configured `font-feature-settings` are included in Preflight ([#9707](https://github.com/tailwindlabs/tailwindcss/pull/9707))
|
|
58
|
+
- Fix fractional values not being parsed properly inside arbitrary properties ([#9705](https://github.com/tailwindlabs/tailwindcss/pull/9705))
|
|
59
|
+
- Fix incorrect selectors when using `@apply` in selectors with combinators and pseudos ([#9722](https://github.com/tailwindlabs/tailwindcss/pull/9722))
|
|
60
|
+
- Fix cannot read properties of undefined (reading 'modifier') ([#9656](https://github.com/tailwindlabs/tailwindcss/pull/9656), [aa979d6](https://github.com/tailwindlabs/tailwindcss/commit/aa979d645f8bf4108c5fc938d7c0ba085b654c31))
|
|
61
|
+
|
|
62
|
+
## [3.2.1] - 2022-10-21
|
|
63
|
+
|
|
64
|
+
### Fixed
|
|
65
|
+
|
|
66
|
+
- Fix missing `supports` in types ([#9616](https://github.com/tailwindlabs/tailwindcss/pull/9616))
|
|
67
|
+
- Fix missing PostCSS dependencies in the CLI ([#9617](https://github.com/tailwindlabs/tailwindcss/pull/9617))
|
|
68
|
+
- Ensure `micromatch` is a proper CLI dependency ([#9620](https://github.com/tailwindlabs/tailwindcss/pull/9620))
|
|
69
|
+
- Ensure modifier values exist when using a `modifiers` object for `matchVariant` ([ba6551db0f2726461371b4f3c6cd4c7090888504](https://github.com/tailwindlabs/tailwindcss/commit/ba6551db0f2726461371b4f3c6cd4c7090888504))
|
|
70
|
+
|
|
71
|
+
## [3.2.0] - 2022-10-19
|
|
72
|
+
|
|
73
|
+
### Added
|
|
74
|
+
|
|
75
|
+
- Add new `@config` directive ([#9405](https://github.com/tailwindlabs/tailwindcss/pull/9405))
|
|
76
|
+
- Add new `relative: true` option to resolve content paths relative to the config file ([#9396](https://github.com/tailwindlabs/tailwindcss/pull/9396))
|
|
77
|
+
- Add new `supports-*` variant ([#9453](https://github.com/tailwindlabs/tailwindcss/pull/9453))
|
|
78
|
+
- Add new `min-*` and `max-*` variants ([#9558](https://github.com/tailwindlabs/tailwindcss/pull/9558))
|
|
79
|
+
- Add new `aria-*` variants ([#9557](https://github.com/tailwindlabs/tailwindcss/pull/9557), [#9588](https://github.com/tailwindlabs/tailwindcss/pull/9588))
|
|
80
|
+
- Add new `data-*` variants ([#9559](https://github.com/tailwindlabs/tailwindcss/pull/9559), [#9588](https://github.com/tailwindlabs/tailwindcss/pull/9588))
|
|
12
81
|
- Add new `break-keep` utility for `word-break: keep-all` ([#9393](https://github.com/tailwindlabs/tailwindcss/pull/9393))
|
|
82
|
+
- Add new `collapse` utility for `visibility: collapse` ([#9181](https://github.com/tailwindlabs/tailwindcss/pull/9181))
|
|
83
|
+
- Add new `fill-none` utility for `fill: none` ([#9403](https://github.com/tailwindlabs/tailwindcss/pull/9403))
|
|
84
|
+
- Add new `stroke-none` utility for `stroke: none` ([#9403](https://github.com/tailwindlabs/tailwindcss/pull/9403))
|
|
85
|
+
- Add new `place-content-baseline` utility for `place-content: baseline` ([#9498](https://github.com/tailwindlabs/tailwindcss/pull/9498))
|
|
86
|
+
- Add new `place-items-baseline` utility for `place-items: baseline` ([#9507](https://github.com/tailwindlabs/tailwindcss/pull/9507))
|
|
87
|
+
- Add new `content-baseline` utility for `align-content: baseline` ([#9507](https://github.com/tailwindlabs/tailwindcss/pull/9507))
|
|
13
88
|
- Add support for configuring default `font-feature-settings` for a font family ([#9039](https://github.com/tailwindlabs/tailwindcss/pull/9039))
|
|
14
|
-
- Add
|
|
89
|
+
- Add standalone CLI build for 32-bit Linux on ARM (`node16-linux-armv7`) ([#9084](https://github.com/tailwindlabs/tailwindcss/pull/9084))
|
|
15
90
|
- Add future flag to disable color opacity utility plugins ([#9088](https://github.com/tailwindlabs/tailwindcss/pull/9088))
|
|
16
91
|
- Add negative value support for `outline-offset` ([#9136](https://github.com/tailwindlabs/tailwindcss/pull/9136))
|
|
17
|
-
-
|
|
18
|
-
-
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
92
|
+
- Add support for modifiers to `matchUtilities` ([#9541](https://github.com/tailwindlabs/tailwindcss/pull/9541))
|
|
93
|
+
- Allow negating utilities using `min`/`max`/`clamp` ([#9237](https://github.com/tailwindlabs/tailwindcss/pull/9237))
|
|
94
|
+
- Implement fallback plugins when there is ambiguity between plugins when using arbitrary values ([#9376](https://github.com/tailwindlabs/tailwindcss/pull/9376))
|
|
95
|
+
- Support `sort` function in `matchVariant` ([#9423](https://github.com/tailwindlabs/tailwindcss/pull/9423))
|
|
96
|
+
- Upgrade to `postcss-nested` v6.0 ([#9546](https://github.com/tailwindlabs/tailwindcss/pull/9546))
|
|
22
97
|
|
|
23
98
|
### Fixed
|
|
24
99
|
|
|
25
100
|
- Use absolute paths when resolving changed files for resilience against working directory changes ([#9032](https://github.com/tailwindlabs/tailwindcss/pull/9032))
|
|
26
101
|
- Fix ring color utility generation when using `respectDefaultRingColorOpacity` ([#9070](https://github.com/tailwindlabs/tailwindcss/pull/9070))
|
|
27
|
-
- Sort tags before classes when `@
|
|
102
|
+
- Sort tags before classes when `@apply`-ing a selector with joined classes ([#9107](https://github.com/tailwindlabs/tailwindcss/pull/9107))
|
|
28
103
|
- Remove invalid `outline-hidden` utility ([#9147](https://github.com/tailwindlabs/tailwindcss/pull/9147))
|
|
29
104
|
- Honor the `hidden` attribute on elements in preflight ([#9174](https://github.com/tailwindlabs/tailwindcss/pull/9174))
|
|
30
105
|
- Don't stop watching atomically renamed files ([#9173](https://github.com/tailwindlabs/tailwindcss/pull/9173), [#9215](https://github.com/tailwindlabs/tailwindcss/pull/9215))
|
|
31
|
-
-
|
|
32
|
-
- Don't output duplicate utilities ([#9208](https://github.com/tailwindlabs/tailwindcss/pull/9208))
|
|
106
|
+
- Fix duplicate utilities issue causing memory leaks ([#9208](https://github.com/tailwindlabs/tailwindcss/pull/9208))
|
|
33
107
|
- Fix `fontFamily` config TypeScript types ([#9214](https://github.com/tailwindlabs/tailwindcss/pull/9214))
|
|
34
108
|
- Handle variants on complex selector utilities ([#9262](https://github.com/tailwindlabs/tailwindcss/pull/9262))
|
|
35
|
-
-
|
|
109
|
+
- Fix shared config mutation issue ([#9294](https://github.com/tailwindlabs/tailwindcss/pull/9294))
|
|
36
110
|
- Fix ordering of parallel variants ([#9282](https://github.com/tailwindlabs/tailwindcss/pull/9282))
|
|
37
111
|
- Handle variants in utility selectors using `:where()` and `:has()` ([#9309](https://github.com/tailwindlabs/tailwindcss/pull/9309))
|
|
38
|
-
- Improve data type
|
|
112
|
+
- Improve data type analysis for arbitrary values ([#9320](https://github.com/tailwindlabs/tailwindcss/pull/9320))
|
|
39
113
|
- Don't emit generated utilities with invalid uses of theme functions ([#9319](https://github.com/tailwindlabs/tailwindcss/pull/9319))
|
|
40
114
|
- Revert change that only listened for stdin close on TTYs ([#9331](https://github.com/tailwindlabs/tailwindcss/pull/9331))
|
|
41
115
|
- Ignore unset values (like `null` or `undefined`) when resolving the classList for intellisense ([#9385](https://github.com/tailwindlabs/tailwindcss/pull/9385))
|
|
116
|
+
- Improve type checking for formal syntax ([#9349](https://github.com/tailwindlabs/tailwindcss/pull/9349), [#9448](https://github.com/tailwindlabs/tailwindcss/pull/9448))
|
|
117
|
+
- Fix incorrect required `content` key in custom plugin configs ([#9502](https://github.com/tailwindlabs/tailwindcss/pull/9502), [#9545](https://github.com/tailwindlabs/tailwindcss/pull/9545))
|
|
118
|
+
- Fix content path detection on Windows ([#9569](https://github.com/tailwindlabs/tailwindcss/pull/9569))
|
|
119
|
+
- Ensure `--content` is used in the CLI when passed ([#9587](https://github.com/tailwindlabs/tailwindcss/pull/9587))
|
|
42
120
|
|
|
43
121
|
## [3.1.8] - 2022-08-05
|
|
44
122
|
|
|
@@ -135,7 +213,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
135
213
|
- Move `important` selector to the front when `@apply`-ing selector-modifying variants in custom utilities ([#8313](https://github.com/tailwindlabs/tailwindcss/pull/8313))
|
|
136
214
|
- Error when registering an invalid custom variant ([#8345](https://github.com/tailwindlabs/tailwindcss/pull/8345))
|
|
137
215
|
- Create tailwind.config.cjs file in ESM package when running init ([#8363](https://github.com/tailwindlabs/tailwindcss/pull/8363))
|
|
138
|
-
- Fix `
|
|
216
|
+
- Fix `matchVariant` that use at-rules and placeholders ([#8392](https://github.com/tailwindlabs/tailwindcss/pull/8392))
|
|
139
217
|
- Improve types of the `tailwindcss/plugin` ([#8400](https://github.com/tailwindlabs/tailwindcss/pull/8400))
|
|
140
218
|
- Allow returning parallel variants from `addVariant` or `matchVariant` callback functions ([#8455](https://github.com/tailwindlabs/tailwindcss/pull/8455))
|
|
141
219
|
- Try using local `postcss` installation first in the CLI ([#8270](https://github.com/tailwindlabs/tailwindcss/pull/8270))
|
|
@@ -2060,7 +2138,12 @@ No release notes
|
|
|
2060
2138
|
|
|
2061
2139
|
- Everything!
|
|
2062
2140
|
|
|
2063
|
-
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.
|
|
2141
|
+
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.2.4...HEAD
|
|
2142
|
+
[3.2.4]: https://github.com/tailwindlabs/tailwindcss/compare/v3.2.3...v3.2.4
|
|
2143
|
+
[3.2.3]: https://github.com/tailwindlabs/tailwindcss/compare/v3.2.2...v3.2.3
|
|
2144
|
+
[3.2.2]: https://github.com/tailwindlabs/tailwindcss/compare/v3.2.1...v3.2.2
|
|
2145
|
+
[3.2.1]: https://github.com/tailwindlabs/tailwindcss/compare/v3.2.0...v3.2.1
|
|
2146
|
+
[3.2.0]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.8...v3.2.0
|
|
2064
2147
|
[3.1.8]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.7...v3.1.8
|
|
2065
2148
|
[3.1.7]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.6...v3.1.7
|
|
2066
2149
|
[3.1.6]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.5...v3.1.6
|
package/README.md
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
<p align="center">
|
|
2
|
-
<a href="https://tailwindcss.com
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
2
|
+
<a href="https://tailwindcss.com" target="_blank">
|
|
3
|
+
<picture>
|
|
4
|
+
<source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/HEAD/.github/logo-dark.svg">
|
|
5
|
+
<source media="(prefers-color-scheme: light)" srcset="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/HEAD/.github/logo-light.svg">
|
|
6
|
+
<img alt="Tailwind CSS" src="https://raw.githubusercontent.com/tailwindlabs/tailwindcss/HEAD/.github/logo-light.svg" width="350" height="70" style="max-width: 100%;">
|
|
7
|
+
</picture>
|
|
7
8
|
</a>
|
|
8
9
|
</p>
|
|
9
10
|
|
package/lib/cli/build/index.js
CHANGED
|
@@ -35,7 +35,11 @@ async function build(args, configs) {
|
|
|
35
35
|
let configPath = args["--config"] ? args["--config"] : ((defaultPath)=>_fs.default.existsSync(defaultPath) ? defaultPath : null)(_path.default.resolve(`./${configs.tailwind}`));
|
|
36
36
|
let processor = await (0, _pluginJs.createProcessor)(args, configPath);
|
|
37
37
|
if (shouldWatch) {
|
|
38
|
-
|
|
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
|
+
}
|
|
39
43
|
process.stdin.resume();
|
|
40
44
|
await processor.watch();
|
|
41
45
|
} else {
|
package/lib/cli/build/plugin.js
CHANGED
|
@@ -25,6 +25,7 @@ const _contentJs = require("../../lib/content.js");
|
|
|
25
25
|
const _watchingJs = require("./watching.js");
|
|
26
26
|
const _fastGlob = /*#__PURE__*/ _interopRequireDefault(require("fast-glob"));
|
|
27
27
|
const _findAtConfigPathJs = require("../../lib/findAtConfigPath.js");
|
|
28
|
+
const _log = /*#__PURE__*/ _interopRequireDefault(require("../../util/log"));
|
|
28
29
|
function _interopRequireDefault(obj) {
|
|
29
30
|
return obj && obj.__esModule ? obj : {
|
|
30
31
|
default: obj
|
|
@@ -98,10 +99,10 @@ function loadBuiltinPostcssPlugins() {
|
|
|
98
99
|
rule.remove();
|
|
99
100
|
}
|
|
100
101
|
});
|
|
101
|
-
}
|
|
102
|
+
}
|
|
102
103
|
],
|
|
103
104
|
[],
|
|
104
|
-
{}
|
|
105
|
+
{}
|
|
105
106
|
];
|
|
106
107
|
}
|
|
107
108
|
let state = {
|
|
@@ -124,7 +125,7 @@ let state = {
|
|
|
124
125
|
dynamic: this.contentPaths.filter((contentPath)=>contentPath.glob !== undefined).map((contentPath)=>contentPath.pattern)
|
|
125
126
|
};
|
|
126
127
|
},
|
|
127
|
-
loadConfig (configPath) {
|
|
128
|
+
loadConfig (configPath, content) {
|
|
128
129
|
if (this.watcher && configPath) {
|
|
129
130
|
this.refreshConfigDependencies(configPath);
|
|
130
131
|
}
|
|
@@ -135,6 +136,10 @@ let state = {
|
|
|
135
136
|
files: []
|
|
136
137
|
}
|
|
137
138
|
});
|
|
139
|
+
// Override content files if `--content` has been passed explicitly
|
|
140
|
+
if ((content === null || content === void 0 ? void 0 : content.length) > 0) {
|
|
141
|
+
config.content.files = content;
|
|
142
|
+
}
|
|
138
143
|
return config;
|
|
139
144
|
},
|
|
140
145
|
refreshConfigDependencies (configPath) {
|
|
@@ -165,15 +170,15 @@ let state = {
|
|
|
165
170
|
let rawContent = this.config.content.files.filter((file)=>{
|
|
166
171
|
return file !== null && typeof file === "object";
|
|
167
172
|
});
|
|
168
|
-
for (let { raw:
|
|
169
|
-
|
|
170
|
-
content:
|
|
173
|
+
for (let { raw: htmlContent , extension ="html" } of rawContent){
|
|
174
|
+
content.push({
|
|
175
|
+
content: htmlContent,
|
|
171
176
|
extension
|
|
172
177
|
});
|
|
173
178
|
}
|
|
174
179
|
return content;
|
|
175
180
|
},
|
|
176
|
-
getContext ({ createContext , cliConfigPath , root , result }) {
|
|
181
|
+
getContext ({ createContext , cliConfigPath , root , result , content }) {
|
|
177
182
|
if (this.context) {
|
|
178
183
|
this.context.changedContent = this.changedContent.splice(0);
|
|
179
184
|
return this.context;
|
|
@@ -183,7 +188,7 @@ let state = {
|
|
|
183
188
|
let configPath = (ref = (0, _findAtConfigPathJs.findAtConfigPath)(root, result)) !== null && ref !== void 0 ? ref : cliConfigPath;
|
|
184
189
|
_shared.env.DEBUG && console.timeEnd("Searching for config");
|
|
185
190
|
_shared.env.DEBUG && console.time("Loading config");
|
|
186
|
-
let config = this.loadConfig(configPath);
|
|
191
|
+
let config = this.loadConfig(configPath, content);
|
|
187
192
|
_shared.env.DEBUG && console.timeEnd("Loading config");
|
|
188
193
|
_shared.env.DEBUG && console.time("Creating context");
|
|
189
194
|
this.context = createContext(config, []);
|
|
@@ -208,12 +213,24 @@ let state = {
|
|
|
208
213
|
}
|
|
209
214
|
};
|
|
210
215
|
async function createProcessor(args, cliConfigPath) {
|
|
216
|
+
var ref;
|
|
211
217
|
let postcss = (0, _deps.loadPostcss)();
|
|
212
218
|
let input = args["--input"];
|
|
213
219
|
let output = args["--output"];
|
|
214
220
|
let includePostCss = args["--postcss"];
|
|
215
221
|
let customPostCssPath = typeof args["--postcss"] === "string" ? args["--postcss"] : undefined;
|
|
216
222
|
let [beforePlugins, afterPlugins, postcssOptions] = includePostCss ? await loadPostCssPlugins(customPostCssPath) : loadBuiltinPostcssPlugins();
|
|
223
|
+
if (args["--purge"]) {
|
|
224
|
+
_log.default.warn("purge-flag-deprecated", [
|
|
225
|
+
"The `--purge` flag has been deprecated.",
|
|
226
|
+
"Please use `--content` instead."
|
|
227
|
+
]);
|
|
228
|
+
if (!args["--content"]) {
|
|
229
|
+
args["--content"] = args["--purge"];
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
var ref1;
|
|
233
|
+
let content = (ref1 = (ref = args["--content"]) === null || ref === void 0 ? void 0 : ref.split(/(?<!{[^}]+),/)) !== null && ref1 !== void 0 ? ref1 : [];
|
|
217
234
|
let tailwindPlugin = ()=>{
|
|
218
235
|
return {
|
|
219
236
|
postcssPlugin: "tailwindcss",
|
|
@@ -227,7 +244,8 @@ async function createProcessor(args, cliConfigPath) {
|
|
|
227
244
|
createContext,
|
|
228
245
|
cliConfigPath,
|
|
229
246
|
root,
|
|
230
|
-
result
|
|
247
|
+
result,
|
|
248
|
+
content
|
|
231
249
|
});
|
|
232
250
|
};
|
|
233
251
|
})(root, result);
|
|
@@ -242,7 +260,7 @@ async function createProcessor(args, cliConfigPath) {
|
|
|
242
260
|
!args["--minify"] && _utils.formatNodes,
|
|
243
261
|
...afterPlugins,
|
|
244
262
|
!args["--no-autoprefixer"] && (0, _deps.loadAutoprefixer)(),
|
|
245
|
-
args["--minify"] && (0, _deps.loadCssNano)()
|
|
263
|
+
args["--minify"] && (0, _deps.loadCssNano)()
|
|
246
264
|
].filter(Boolean);
|
|
247
265
|
/** @type {import('postcss').Processor} */ // @ts-ignore
|
|
248
266
|
let processor = postcss(plugins);
|
|
@@ -265,18 +283,45 @@ async function createProcessor(args, cliConfigPath) {
|
|
|
265
283
|
from: input,
|
|
266
284
|
to: output
|
|
267
285
|
})).then((result)=>{
|
|
286
|
+
if (!state.watcher) {
|
|
287
|
+
return result;
|
|
288
|
+
}
|
|
289
|
+
_shared.env.DEBUG && console.time("Recording PostCSS dependencies");
|
|
290
|
+
for (let message of result.messages){
|
|
291
|
+
if (message.type === "dependency") {
|
|
292
|
+
state.contextDependencies.add(message.file);
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
_shared.env.DEBUG && console.timeEnd("Recording PostCSS dependencies");
|
|
296
|
+
// TODO: This needs to be in a different spot
|
|
297
|
+
_shared.env.DEBUG && console.time("Watch new files");
|
|
298
|
+
state.watcher.refreshWatchedFiles();
|
|
299
|
+
_shared.env.DEBUG && console.timeEnd("Watch new files");
|
|
300
|
+
return result;
|
|
301
|
+
}).then((result)=>{
|
|
268
302
|
if (!output) {
|
|
269
303
|
process.stdout.write(result.css);
|
|
270
304
|
return;
|
|
271
305
|
}
|
|
272
306
|
return Promise.all([
|
|
273
|
-
(0, _utils.outputFile)(
|
|
274
|
-
result.map && (0, _utils.outputFile)(
|
|
307
|
+
(0, _utils.outputFile)(result.opts.to, result.css),
|
|
308
|
+
result.map && (0, _utils.outputFile)(result.opts.to + ".map", result.map.toString())
|
|
275
309
|
]);
|
|
276
310
|
}).then(()=>{
|
|
277
311
|
let end = process.hrtime.bigint();
|
|
278
312
|
console.error();
|
|
279
313
|
console.error("Done in", (end - start) / BigInt(1e6) + "ms.");
|
|
314
|
+
}).then(()=>{}, (err)=>{
|
|
315
|
+
// TODO: If an initial build fails we can't easily pick up any PostCSS dependencies
|
|
316
|
+
// that were collected before the error occurred
|
|
317
|
+
// The result is not stored on the error so we have to store it externally
|
|
318
|
+
// and pull the messages off of it here somehow
|
|
319
|
+
// This results in a less than ideal DX because the watcher will not pick up
|
|
320
|
+
// changes to imported CSS if one of them caused an error during the initial build
|
|
321
|
+
// If you fix it and then save the main CSS file so there's no error
|
|
322
|
+
// The watcher will start watching the imported CSS files and will be
|
|
323
|
+
// resilient to future errors.
|
|
324
|
+
console.error(err);
|
|
280
325
|
});
|
|
281
326
|
}
|
|
282
327
|
/**
|
|
@@ -37,22 +37,70 @@ function createWatcher(args, { state , rebuild }) {
|
|
|
37
37
|
pollInterval: pollInterval
|
|
38
38
|
} : false
|
|
39
39
|
});
|
|
40
|
+
// A queue of rebuilds, file reads, etc… to run
|
|
40
41
|
let chain = Promise.resolve();
|
|
41
|
-
|
|
42
|
-
|
|
42
|
+
/**
|
|
43
|
+
* A list of files that have been changed since the last rebuild
|
|
44
|
+
*
|
|
45
|
+
* @type {{file: string, content: () => Promise<string>, extension: string}[]}
|
|
46
|
+
*/ let changedContent = [];
|
|
47
|
+
/**
|
|
48
|
+
* A list of files for which a rebuild has already been queued.
|
|
49
|
+
* This is used to prevent duplicate rebuilds when multiple events are fired for the same file.
|
|
50
|
+
* The rebuilt file is cleared from this list when it's associated rebuild has _started_
|
|
51
|
+
* This is because if the file is changed during a rebuild it won't trigger a new rebuild which it should
|
|
52
|
+
**/ let pendingRebuilds = new Set();
|
|
53
|
+
let _timer;
|
|
54
|
+
let _reject;
|
|
55
|
+
/**
|
|
56
|
+
* Rebuilds the changed files and resolves when the rebuild is
|
|
57
|
+
* complete regardless of whether it was successful or not
|
|
58
|
+
*/ async function rebuildAndContinue() {
|
|
59
|
+
let changes = changedContent.splice(0);
|
|
60
|
+
// There are no changes to rebuild so we can just do nothing
|
|
61
|
+
if (changes.length === 0) {
|
|
62
|
+
return Promise.resolve();
|
|
63
|
+
}
|
|
64
|
+
// Clear all pending rebuilds for the about-to-be-built files
|
|
65
|
+
changes.forEach((change)=>pendingRebuilds.delete(change.file));
|
|
66
|
+
// Resolve the promise even when the rebuild fails
|
|
67
|
+
return rebuild(changes).then(()=>{}, ()=>{});
|
|
68
|
+
}
|
|
43
69
|
/**
|
|
44
70
|
*
|
|
45
71
|
* @param {*} file
|
|
46
72
|
* @param {(() => Promise<string>) | null} content
|
|
47
|
-
|
|
73
|
+
* @param {boolean} skipPendingCheck
|
|
74
|
+
* @returns {Promise<void>}
|
|
75
|
+
*/ function recordChangedFile(file, content = null, skipPendingCheck = false) {
|
|
48
76
|
file = _path.default.resolve(file);
|
|
49
|
-
|
|
77
|
+
// Applications like Vim/Neovim fire both rename and change events in succession for atomic writes
|
|
78
|
+
// In that case rebuild has already been queued by rename, so can be skipped in change
|
|
79
|
+
if (pendingRebuilds.has(file) && !skipPendingCheck) {
|
|
80
|
+
return Promise.resolve();
|
|
81
|
+
}
|
|
82
|
+
// Mark that a rebuild of this file is going to happen
|
|
83
|
+
// It MUST happen synchronously before the rebuild is queued for this to be effective
|
|
84
|
+
pendingRebuilds.add(file);
|
|
50
85
|
changedContent.push({
|
|
51
86
|
file,
|
|
52
|
-
content,
|
|
87
|
+
content: content !== null && content !== void 0 ? content : ()=>_fs.default.promises.readFile(file, "utf8"),
|
|
53
88
|
extension: _path.default.extname(file).slice(1)
|
|
54
89
|
});
|
|
55
|
-
|
|
90
|
+
if (_timer) {
|
|
91
|
+
clearTimeout(_timer);
|
|
92
|
+
_reject();
|
|
93
|
+
}
|
|
94
|
+
// If a rebuild is already in progress we don't want to start another one until the 10ms timer has expired
|
|
95
|
+
chain = chain.then(()=>new Promise((resolve, reject)=>{
|
|
96
|
+
_timer = setTimeout(resolve, 10);
|
|
97
|
+
_reject = reject;
|
|
98
|
+
}));
|
|
99
|
+
// Resolves once this file has been rebuilt (or the rebuild for this file has failed)
|
|
100
|
+
// This queues as many rebuilds as there are changed files
|
|
101
|
+
// But those rebuilds happen after some delay
|
|
102
|
+
// And will immediately resolve if there are no changes
|
|
103
|
+
chain = chain.then(rebuildAndContinue, rebuildAndContinue);
|
|
56
104
|
return chain;
|
|
57
105
|
}
|
|
58
106
|
watcher.on("change", (file)=>recordChangedFile(file));
|
|
@@ -91,15 +139,32 @@ function createWatcher(args, { state , rebuild }) {
|
|
|
91
139
|
if (pendingRebuilds.has(filePath)) {
|
|
92
140
|
return;
|
|
93
141
|
}
|
|
142
|
+
// We'll go ahead and add the file to the pending rebuilds list here
|
|
143
|
+
// It'll be removed when the rebuild starts unless the read fails
|
|
144
|
+
// which will be taken care of as well
|
|
94
145
|
pendingRebuilds.add(filePath);
|
|
95
|
-
|
|
96
|
-
let content;
|
|
146
|
+
async function enqueue() {
|
|
97
147
|
try {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
148
|
+
// We need to read the file as early as possible outside of the chain
|
|
149
|
+
// because it may be gone by the time we get to it. doing the read
|
|
150
|
+
// immediately increases the chance that the file is still there
|
|
151
|
+
let content = await (0, _utilsJs.readFileWithRetries)(_path.default.resolve(filePath));
|
|
152
|
+
if (content === undefined) {
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
// This will push the rebuild onto the chain
|
|
156
|
+
// We MUST skip the rebuild check here otherwise the rebuild will never happen on Linux
|
|
157
|
+
// This is because the order of events and timing is different on Linux
|
|
158
|
+
// @ts-ignore: TypeScript isn't picking up that content is a string here
|
|
159
|
+
await recordChangedFile(filePath, ()=>content, true);
|
|
160
|
+
} catch {
|
|
161
|
+
// If reading the file fails, it's was probably a deleted temporary file
|
|
162
|
+
// So we can ignore it and no rebuild is needed
|
|
101
163
|
}
|
|
102
|
-
|
|
164
|
+
}
|
|
165
|
+
enqueue().then(()=>{
|
|
166
|
+
// If the file read fails we still need to make sure the file isn't stuck in the pending rebuilds list
|
|
167
|
+
pendingRebuilds.delete(filePath);
|
|
103
168
|
});
|
|
104
169
|
});
|
|
105
170
|
return {
|
package/lib/cli.js
CHANGED
|
@@ -72,7 +72,7 @@ let commands = {
|
|
|
72
72
|
description: "Output file"
|
|
73
73
|
},
|
|
74
74
|
"--watch": {
|
|
75
|
-
type: Boolean,
|
|
75
|
+
type: oneOf(String, Boolean),
|
|
76
76
|
description: "Watch for changes and rebuild as needed"
|
|
77
77
|
},
|
|
78
78
|
"--poll": {
|
|
@@ -123,7 +123,7 @@ if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.
|
|
|
123
123
|
(0, _help.help)({
|
|
124
124
|
usage: [
|
|
125
125
|
"tailwindcss [--input input.css] [--output output.css] [--watch] [options...]",
|
|
126
|
-
"tailwindcss init [--full] [--postcss] [options...]"
|
|
126
|
+
"tailwindcss init [--full] [--postcss] [options...]"
|
|
127
127
|
],
|
|
128
128
|
commands: Object.keys(commands).filter((command)=>command !== "build").map((command)=>`${command} [options]`),
|
|
129
129
|
options: {
|
|
@@ -171,8 +171,8 @@ let args = (()=>{
|
|
|
171
171
|
for(let i = result["_"].length - 1; i >= 0; --i){
|
|
172
172
|
let flag = result["_"][i];
|
|
173
173
|
if (!flag.startsWith("-")) continue;
|
|
174
|
-
let flagName = flag;
|
|
175
|
-
let handler = flags[
|
|
174
|
+
let [flagName, flagValue] = flag.split("=");
|
|
175
|
+
let handler = flags[flagName];
|
|
176
176
|
// Resolve flagName & handler
|
|
177
177
|
while(typeof handler === "string"){
|
|
178
178
|
flagName = handler;
|
|
@@ -181,14 +181,24 @@ let args = (()=>{
|
|
|
181
181
|
if (!handler) continue;
|
|
182
182
|
let args = [];
|
|
183
183
|
let offset = i + 1;
|
|
184
|
-
//
|
|
185
|
-
|
|
186
|
-
args
|
|
184
|
+
// --flag value syntax was used so we need to pull `value` from `args`
|
|
185
|
+
if (flagValue === undefined) {
|
|
186
|
+
// Parse args for current flag
|
|
187
|
+
while(result["_"][offset] && !result["_"][offset].startsWith("-")){
|
|
188
|
+
args.push(result["_"][offset++]);
|
|
189
|
+
}
|
|
190
|
+
// Cleanup manually parsed flags + args
|
|
191
|
+
result["_"].splice(i, 1 + args.length);
|
|
192
|
+
// No args were provided, use default value defined in handler
|
|
193
|
+
// One arg was provided, use that directly
|
|
194
|
+
// Multiple args were provided so pass them all in an array
|
|
195
|
+
flagValue = args.length === 0 ? undefined : args.length === 1 ? args[0] : args;
|
|
196
|
+
} else {
|
|
197
|
+
// Remove the whole flag from the args array
|
|
198
|
+
result["_"].splice(i, 1);
|
|
187
199
|
}
|
|
188
|
-
// Cleanup manually parsed flags + args
|
|
189
|
-
result["_"].splice(i, 1 + args.length);
|
|
190
200
|
// Set the resolved value in the `result` object
|
|
191
|
-
result[flagName] = handler.type(
|
|
201
|
+
result[flagName] = handler.type(flagValue, flagName);
|
|
192
202
|
}
|
|
193
203
|
// Ensure that the `command` is always the first argument in the `args`.
|
|
194
204
|
// This is important so that we don't have to check if a default command
|