tailwindcss 0.0.0-insiders.aedfc6c → 0.0.0-insiders.aee196e
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 +99 -5
- package/defaultTheme.d.ts +2 -1
- package/lib/cli-peer-dependencies.js +8 -3
- package/lib/cli.js +116 -72
- package/lib/corePlugins.js +120 -86
- package/lib/css/preflight.css +0 -8
- package/lib/featureFlags.js +8 -6
- package/lib/index.js +1 -2
- package/lib/lib/cacheInvalidation.js +32 -14
- package/lib/lib/collapseAdjacentRules.js +1 -2
- package/lib/lib/defaultExtractor.js +216 -32
- package/lib/lib/evaluateTailwindFunctions.js +58 -14
- package/lib/lib/expandApplyAtRules.js +51 -24
- package/lib/lib/expandTailwindAtRules.js +40 -26
- package/lib/lib/generateRules.js +125 -50
- package/lib/lib/regex.js +52 -0
- package/lib/lib/resolveDefaultsAtRules.js +56 -45
- package/lib/lib/setupContextUtils.js +138 -79
- package/lib/lib/setupTrackingContext.js +7 -9
- package/lib/lib/sharedState.js +1 -2
- package/lib/lib/substituteScreenAtRules.js +1 -2
- package/lib/postcss-plugins/nesting/plugin.js +1 -2
- package/lib/util/buildMediaQuery.js +1 -2
- package/lib/util/cloneDeep.js +2 -4
- package/lib/util/color.js +26 -36
- package/lib/util/createPlugin.js +1 -2
- package/lib/util/createUtilityPlugin.js +1 -2
- package/lib/util/dataTypes.js +11 -16
- package/lib/util/flattenColorPalette.js +2 -5
- package/lib/util/formatVariantSelector.js +65 -57
- package/lib/util/getAllConfigs.js +10 -5
- package/lib/util/isValidArbitraryValue.js +1 -2
- package/lib/util/log.js +2 -3
- package/lib/util/negateValue.js +1 -2
- package/lib/util/normalizeConfig.js +33 -23
- package/lib/util/normalizeScreens.js +1 -2
- package/lib/util/parseAnimationValue.js +1 -2
- package/lib/util/parseBoxShadowValue.js +2 -43
- package/lib/util/pluginUtils.js +11 -3
- package/lib/util/removeAlphaVariables.js +18 -0
- package/lib/util/resolveConfig.js +57 -56
- package/lib/util/splitAtTopLevelOnly.js +90 -0
- package/lib/util/transformThemeValue.js +4 -2
- package/lib/util/validateConfig.js +21 -0
- package/lib/util/withAlphaVariable.js +5 -5
- package/package.json +20 -18
- package/peers/index.js +3598 -1501
- package/plugin.d.ts +10 -5
- package/scripts/generate-types.js +53 -0
- package/scripts/type-utils.js +27 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +104 -27
- package/src/corePlugins.js +77 -42
- package/src/css/preflight.css +0 -8
- package/src/featureFlags.js +2 -2
- package/src/lib/defaultExtractor.js +193 -35
- package/src/lib/evaluateTailwindFunctions.js +56 -6
- package/src/lib/expandApplyAtRules.js +60 -7
- package/src/lib/expandTailwindAtRules.js +4 -4
- package/src/lib/generateRules.js +87 -14
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +53 -36
- package/src/lib/setupContextUtils.js +117 -39
- package/src/lib/setupTrackingContext.js +4 -0
- package/src/util/color.js +20 -18
- package/src/util/dataTypes.js +4 -6
- package/src/util/formatVariantSelector.js +82 -63
- package/src/util/getAllConfigs.js +7 -0
- package/src/util/log.js +1 -1
- package/src/util/normalizeConfig.js +0 -8
- package/src/util/parseBoxShadowValue.js +3 -50
- package/src/util/pluginUtils.js +13 -1
- package/src/util/removeAlphaVariables.js +24 -0
- package/src/util/resolveConfig.js +66 -52
- package/src/util/splitAtTopLevelOnly.js +71 -0
- package/src/util/toPath.js +1 -1
- package/src/util/transformThemeValue.js +4 -2
- package/src/util/validateConfig.js +13 -0
- package/src/util/withAlphaVariable.js +1 -1
- package/stubs/defaultConfig.stub.js +2 -1
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +33 -29
- package/types/generated/default-theme.d.ts +331 -0
- package/types/index.d.ts +7 -1
- package/types.d.ts +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,16 +9,95 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Fixed
|
|
11
11
|
|
|
12
|
+
- Fix usage on Node 12.x ([b4e637e](https://github.com/tailwindlabs/tailwindcss/commit/b4e637e2e096a9d6f2210efba9541f6fd4f28e56))
|
|
13
|
+
- Handle theme keys with slashes when using `theme()` in CSS ([#8831](https://github.com/tailwindlabs/tailwindcss/pull/8831))
|
|
14
|
+
|
|
15
|
+
## [3.1.5] - 2022-07-07
|
|
16
|
+
|
|
17
|
+
### Added
|
|
18
|
+
|
|
19
|
+
- Support configuring a default `font-weight` for each font size utility ([#8763](https://github.com/tailwindlabs/tailwindcss/pull/8763))
|
|
20
|
+
- Add support for alpha values in safe list ([#8774](https://github.com/tailwindlabs/tailwindcss/pull/8774))
|
|
21
|
+
|
|
22
|
+
### Fixed
|
|
23
|
+
|
|
24
|
+
- Improve types to support fallback values in the CSS-in-JS syntax used in plugin APIs ([#8762](https://github.com/tailwindlabs/tailwindcss/pull/8762))
|
|
25
|
+
- Support including `tailwindcss` and `autoprefixer` in `postcss.config.js` in standalone CLI ([#8769](https://github.com/tailwindlabs/tailwindcss/pull/8769))
|
|
26
|
+
- Fix using special-characters as prefixes ([#8772](https://github.com/tailwindlabs/tailwindcss/pull/8772))
|
|
27
|
+
- Don’t prefix classes used within arbitrary variants ([#8773](https://github.com/tailwindlabs/tailwindcss/pull/8773))
|
|
28
|
+
- Add more explicit types for the default theme ([#8780](https://github.com/tailwindlabs/tailwindcss/pull/8780))
|
|
29
|
+
|
|
30
|
+
## [3.1.4] - 2022-06-21
|
|
31
|
+
|
|
32
|
+
### Fixed
|
|
33
|
+
|
|
34
|
+
- Provide default to `<alpha-value>` when using `theme()` ([#8652](https://github.com/tailwindlabs/tailwindcss/pull/8652))
|
|
35
|
+
- Detect arbitrary variants with quotes ([#8687](https://github.com/tailwindlabs/tailwindcss/pull/8687))
|
|
36
|
+
- Don’t add spaces around raw `/` that are preceded by numbers ([#8688](https://github.com/tailwindlabs/tailwindcss/pull/8688))
|
|
37
|
+
|
|
38
|
+
## [3.1.3] - 2022-06-14
|
|
39
|
+
|
|
40
|
+
### Fixed
|
|
41
|
+
|
|
42
|
+
- Fix extraction of multi-word utilities with arbitrary values and quotes ([#8604](https://github.com/tailwindlabs/tailwindcss/pull/8604))
|
|
43
|
+
- Fix casing of import of `corePluginList` type definition ([#8587](https://github.com/tailwindlabs/tailwindcss/pull/8587))
|
|
44
|
+
- Ignore PostCSS nodes returned by `addVariant` ([#8608](https://github.com/tailwindlabs/tailwindcss/pull/8608))
|
|
45
|
+
- Fix missing spaces around arithmetic operators ([#8615](https://github.com/tailwindlabs/tailwindcss/pull/8615))
|
|
46
|
+
- Detect alpha value in CSS `theme()` function when using quotes ([#8625](https://github.com/tailwindlabs/tailwindcss/pull/8625))
|
|
47
|
+
- Fix "Maximum call stack size exceeded" bug ([#8636](https://github.com/tailwindlabs/tailwindcss/pull/8636))
|
|
48
|
+
- Allow functions returning parallel variants to mutate the container ([#8622](https://github.com/tailwindlabs/tailwindcss/pull/8622))
|
|
49
|
+
- Remove text opacity CSS variables from `::marker` ([#8622](https://github.com/tailwindlabs/tailwindcss/pull/8622))
|
|
50
|
+
|
|
51
|
+
## [3.1.2] - 2022-06-10
|
|
52
|
+
|
|
53
|
+
### Fixed
|
|
54
|
+
|
|
55
|
+
- Ensure `\` is a valid arbitrary variant token ([#8576](https://github.com/tailwindlabs/tailwindcss/pull/8576))
|
|
56
|
+
- Enable `postcss-import` in the CLI by default in watch mode ([#8574](https://github.com/tailwindlabs/tailwindcss/pull/8574), [#8580](https://github.com/tailwindlabs/tailwindcss/pull/8580))
|
|
57
|
+
|
|
58
|
+
## [3.1.1] - 2022-06-09
|
|
59
|
+
|
|
60
|
+
### Fixed
|
|
61
|
+
|
|
62
|
+
- Fix candidate extractor regression ([#8558](https://github.com/tailwindlabs/tailwindcss/pull/8558))
|
|
63
|
+
- Split `::backdrop` into separate defaults group ([#8567](https://github.com/tailwindlabs/tailwindcss/pull/8567))
|
|
64
|
+
- Fix postcss plugin type ([#8564](https://github.com/tailwindlabs/tailwindcss/pull/8564))
|
|
65
|
+
- Fix class detection in markdown code fences and slim templates ([#8569](https://github.com/tailwindlabs/tailwindcss/pull/8569))
|
|
66
|
+
|
|
67
|
+
## [3.1.0] - 2022-06-08
|
|
68
|
+
|
|
69
|
+
### Fixed
|
|
70
|
+
|
|
12
71
|
- Types: allow for arbitrary theme values (for 3rd party plugins) ([#7926](https://github.com/tailwindlabs/tailwindcss/pull/7926))
|
|
13
72
|
- Don’t split vars with numbers in them inside arbitrary values ([#8091](https://github.com/tailwindlabs/tailwindcss/pull/8091))
|
|
14
73
|
- Require matching prefix when detecting negatives ([#8121](https://github.com/tailwindlabs/tailwindcss/pull/8121))
|
|
15
74
|
- Handle duplicate At Rules without children ([#8122](https://github.com/tailwindlabs/tailwindcss/pull/8122))
|
|
16
75
|
- Allow arbitrary values with commas in `@apply` ([#8125](https://github.com/tailwindlabs/tailwindcss/pull/8125))
|
|
76
|
+
- Fix intellisense for plugins with multiple `@apply` rules ([#8213](https://github.com/tailwindlabs/tailwindcss/pull/8213))
|
|
77
|
+
- Improve type detection for arbitrary color values ([#8201](https://github.com/tailwindlabs/tailwindcss/pull/8201))
|
|
78
|
+
- Support PostCSS config options in config file in CLI ([#8226](https://github.com/tailwindlabs/tailwindcss/pull/8226))
|
|
79
|
+
- Remove default `[hidden]` style in preflight ([#8248](https://github.com/tailwindlabs/tailwindcss/pull/8248))
|
|
80
|
+
- Only check selectors containing base apply candidates for circular dependencies ([#8222](https://github.com/tailwindlabs/tailwindcss/pull/8222))
|
|
81
|
+
- Rewrite default class extractor ([#8204](https://github.com/tailwindlabs/tailwindcss/pull/8204))
|
|
82
|
+
- Move `important` selector to the front when `@apply`-ing selector-modifying variants in custom utilities ([#8313](https://github.com/tailwindlabs/tailwindcss/pull/8313))
|
|
83
|
+
- Error when registering an invalid custom variant ([#8345](https://github.com/tailwindlabs/tailwindcss/pull/8345))
|
|
84
|
+
- Create tailwind.config.cjs file in ESM package when running init ([#8363](https://github.com/tailwindlabs/tailwindcss/pull/8363))
|
|
85
|
+
- Fix `matchVariants` that use at-rules and placeholders ([#8392](https://github.com/tailwindlabs/tailwindcss/pull/8392))
|
|
86
|
+
- Improve types of the `tailwindcss/plugin` ([#8400](https://github.com/tailwindlabs/tailwindcss/pull/8400))
|
|
87
|
+
- Allow returning parallel variants from `addVariant` or `matchVariant` callback functions ([#8455](https://github.com/tailwindlabs/tailwindcss/pull/8455))
|
|
88
|
+
- Try using local `postcss` installation first in the CLI ([#8270](https://github.com/tailwindlabs/tailwindcss/pull/8270))
|
|
89
|
+
- Allow default ring color to be a function ([#7587](https://github.com/tailwindlabs/tailwindcss/pull/7587))
|
|
90
|
+
- Don't inherit `to` value from parent gradients ([#8489](https://github.com/tailwindlabs/tailwindcss/pull/8489))
|
|
91
|
+
- Remove process dependency from log functions ([#8530](https://github.com/tailwindlabs/tailwindcss/pull/8530))
|
|
92
|
+
- Ensure we can use `@import 'tailwindcss/...'` without node_modules ([#8537](https://github.com/tailwindlabs/tailwindcss/pull/8537))
|
|
93
|
+
|
|
94
|
+
### Changed
|
|
95
|
+
|
|
96
|
+
- Only apply hover styles when supported (future) ([#8394](https://github.com/tailwindlabs/tailwindcss/pull/8394))
|
|
97
|
+
- Respect default ring color opacity (future) ([#8448](https://github.com/tailwindlabs/tailwindcss/pull/8448), [3f4005e](https://github.com/tailwindlabs/tailwindcss/commit/3f4005e833445f7549219eb5ae89728cbb3a2630))
|
|
17
98
|
|
|
18
99
|
### Added
|
|
19
100
|
|
|
20
|
-
- Allow default ring color to be a function ([#7587](https://github.com/tailwindlabs/tailwindcss/pull/7587))
|
|
21
|
-
- Add `rgb` and `hsl` color helpers for CSS variables ([#7665](https://github.com/tailwindlabs/tailwindcss/pull/7665))
|
|
22
101
|
- Support PostCSS `Document` nodes ([#7291](https://github.com/tailwindlabs/tailwindcss/pull/7291))
|
|
23
102
|
- Add `text-start` and `text-end` utilities ([#6656](https://github.com/tailwindlabs/tailwindcss/pull/6656))
|
|
24
103
|
- Support customizing class name when using `darkMode: 'class'` ([#5800](https://github.com/tailwindlabs/tailwindcss/pull/5800))
|
|
@@ -26,9 +105,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
26
105
|
- Add new `border-spacing` utilities ([#7102](https://github.com/tailwindlabs/tailwindcss/pull/7102))
|
|
27
106
|
- Add `enabled` variant ([#7905](https://github.com/tailwindlabs/tailwindcss/pull/7905))
|
|
28
107
|
- Add TypeScript types for the `tailwind.config.js` file ([#7891](https://github.com/tailwindlabs/tailwindcss/pull/7891))
|
|
29
|
-
- Add `backdrop` variant ([#7924](https://github.com/tailwindlabs/tailwindcss/pull/7924))
|
|
108
|
+
- Add `backdrop` variant ([#7924](https://github.com/tailwindlabs/tailwindcss/pull/7924), [#8526](https://github.com/tailwindlabs/tailwindcss/pull/8526))
|
|
109
|
+
- Add `grid-flow-dense` utility ([#8193](https://github.com/tailwindlabs/tailwindcss/pull/8193))
|
|
110
|
+
- Add `mix-blend-plus-lighter` utility ([#8288](https://github.com/tailwindlabs/tailwindcss/pull/8288))
|
|
111
|
+
- Add arbitrary variants ([#8299](https://github.com/tailwindlabs/tailwindcss/pull/8299))
|
|
112
|
+
- Add experimental `matchVariant` API ([#8310](https://github.com/tailwindlabs/tailwindcss/pull/8310), [34fd0fb8](https://github.com/tailwindlabs/tailwindcss/commit/34fd0fb82aa574cddc5c7aa3ad7d1af5e3735e5d))
|
|
113
|
+
- Add `prefers-contrast` media query variants ([#8410](https://github.com/tailwindlabs/tailwindcss/pull/8410))
|
|
114
|
+
- Add opacity support when referencing colors with `theme` function ([#8416](https://github.com/tailwindlabs/tailwindcss/pull/8416))
|
|
115
|
+
- Add `postcss-import` support to the CLI ([#8437](https://github.com/tailwindlabs/tailwindcss/pull/8437))
|
|
116
|
+
- Add `optional` variant ([#8486](https://github.com/tailwindlabs/tailwindcss/pull/8486))
|
|
117
|
+
- Add `<alpha-value>` placeholder support for custom colors ([#8501](https://github.com/tailwindlabs/tailwindcss/pull/8501))
|
|
30
118
|
|
|
31
|
-
## [3.0.24] - 2022-
|
|
119
|
+
## [3.0.24] - 2022-04-12
|
|
32
120
|
|
|
33
121
|
### Fixed
|
|
34
122
|
|
|
@@ -1919,7 +2007,13 @@ No release notes
|
|
|
1919
2007
|
|
|
1920
2008
|
- Everything!
|
|
1921
2009
|
|
|
1922
|
-
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.
|
|
2010
|
+
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.5...HEAD
|
|
2011
|
+
[3.1.5]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.4...v3.1.5
|
|
2012
|
+
[3.1.4]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.3...v3.1.4
|
|
2013
|
+
[3.1.3]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.2...v3.1.3
|
|
2014
|
+
[3.1.2]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.1...v3.1.2
|
|
2015
|
+
[3.1.1]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.0...v3.1.1
|
|
2016
|
+
[3.1.0]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.24...v3.1.0
|
|
1923
2017
|
[3.0.24]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.23...v3.0.24
|
|
1924
2018
|
[3.0.23]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.22...v3.0.23
|
|
1925
2019
|
[3.0.22]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.21...v3.0.22
|
package/defaultTheme.d.ts
CHANGED
|
@@ -2,11 +2,16 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", {
|
|
3
3
|
value: true
|
|
4
4
|
});
|
|
5
|
+
exports.lazyPostcss = lazyPostcss;
|
|
6
|
+
exports.lazyPostcssImport = lazyPostcssImport;
|
|
5
7
|
exports.lazyAutoprefixer = lazyAutoprefixer;
|
|
6
8
|
exports.lazyCssnano = lazyCssnano;
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
9
|
+
function lazyPostcss() {
|
|
10
|
+
return require("postcss");
|
|
11
|
+
}
|
|
12
|
+
function lazyPostcssImport() {
|
|
13
|
+
return require("postcss-import");
|
|
14
|
+
}
|
|
10
15
|
function lazyAutoprefixer() {
|
|
11
16
|
return require("autoprefixer");
|
|
12
17
|
}
|
package/lib/cli.js
CHANGED
|
@@ -9,6 +9,8 @@ var _postcssLoadConfig = _interopRequireDefault(require("postcss-load-config"));
|
|
|
9
9
|
var _lilconfig = require("lilconfig");
|
|
10
10
|
var _plugins // Little bit scary, looking at private/internal API
|
|
11
11
|
= _interopRequireDefault(require("postcss-load-config/src/plugins"));
|
|
12
|
+
var _options // Little bit scary, looking at private/internal API
|
|
13
|
+
= _interopRequireDefault(require("postcss-load-config/src/options"));
|
|
12
14
|
var _processTailwindFeatures = _interopRequireDefault(require("./processTailwindFeatures"));
|
|
13
15
|
var _resolveConfig = _interopRequireDefault(require("../resolveConfig"));
|
|
14
16
|
var _fastGlob = _interopRequireDefault(require("fast-glob"));
|
|
@@ -16,6 +18,7 @@ var _getModuleDependencies = _interopRequireDefault(require("./lib/getModuleDepe
|
|
|
16
18
|
var _log = _interopRequireDefault(require("./util/log"));
|
|
17
19
|
var _packageJson = _interopRequireDefault(require("../package.json"));
|
|
18
20
|
var _normalizePath = _interopRequireDefault(require("normalize-path"));
|
|
21
|
+
var _validateConfigJs = require("./util/validateConfig.js");
|
|
19
22
|
function _interopRequireDefault(obj) {
|
|
20
23
|
return obj && obj.__esModule ? obj : {
|
|
21
24
|
default: obj
|
|
@@ -24,6 +27,22 @@ function _interopRequireDefault(obj) {
|
|
|
24
27
|
let env = {
|
|
25
28
|
DEBUG: process.env.DEBUG !== undefined && process.env.DEBUG !== "0"
|
|
26
29
|
};
|
|
30
|
+
function isESM() {
|
|
31
|
+
const pkgPath = _path.default.resolve("./package.json");
|
|
32
|
+
try {
|
|
33
|
+
let pkg = JSON.parse(_fs.default.readFileSync(pkgPath, "utf8"));
|
|
34
|
+
return pkg.type && pkg.type === "module";
|
|
35
|
+
} catch (err) {
|
|
36
|
+
return false;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
let configs = isESM() ? {
|
|
40
|
+
tailwind: "tailwind.config.cjs",
|
|
41
|
+
postcss: "postcss.config.cjs"
|
|
42
|
+
} : {
|
|
43
|
+
tailwind: "tailwind.config.js",
|
|
44
|
+
postcss: "postcss.config.js"
|
|
45
|
+
};
|
|
27
46
|
// ---
|
|
28
47
|
function indentRecursive(node, indent = 0) {
|
|
29
48
|
node.each && node.each((child, i)=>{
|
|
@@ -53,10 +72,8 @@ function drainStdin() {
|
|
|
53
72
|
process.stdin.on("data", (chunk)=>{
|
|
54
73
|
result += chunk;
|
|
55
74
|
});
|
|
56
|
-
process.stdin.on("end", ()=>resolve(result)
|
|
57
|
-
);
|
|
58
|
-
process.stdin.on("error", (err)=>reject(err)
|
|
59
|
-
);
|
|
75
|
+
process.stdin.on("end", ()=>resolve(result));
|
|
76
|
+
process.stdin.on("error", (err)=>reject(err));
|
|
60
77
|
});
|
|
61
78
|
}
|
|
62
79
|
function help({ message , usage , commands: commands1 , options }) {
|
|
@@ -128,21 +145,24 @@ function oneOf(...options) {
|
|
|
128
145
|
manualParsing: true
|
|
129
146
|
});
|
|
130
147
|
}
|
|
148
|
+
function loadPostcss() {
|
|
149
|
+
// Try to load a local `postcss` version first
|
|
150
|
+
try {
|
|
151
|
+
return require("postcss");
|
|
152
|
+
} catch {}
|
|
153
|
+
return (0, _indexJs).lazyPostcss();
|
|
154
|
+
}
|
|
131
155
|
let commands = {
|
|
132
156
|
init: {
|
|
133
157
|
run: init,
|
|
134
158
|
args: {
|
|
135
159
|
"--full": {
|
|
136
160
|
type: Boolean,
|
|
137
|
-
description:
|
|
161
|
+
description: `Initialize a full \`${configs.tailwind}\` file`
|
|
138
162
|
},
|
|
139
163
|
"--postcss": {
|
|
140
164
|
type: Boolean,
|
|
141
|
-
description:
|
|
142
|
-
},
|
|
143
|
-
"--types": {
|
|
144
|
-
type: Boolean,
|
|
145
|
-
description: "Add TypeScript types for the `tailwind.config.js` file"
|
|
165
|
+
description: `Initialize a \`${configs.postcss}\` file`
|
|
146
166
|
},
|
|
147
167
|
"-f": "--full",
|
|
148
168
|
"-p": "--postcss"
|
|
@@ -207,16 +227,13 @@ let sharedFlags = {
|
|
|
207
227
|
},
|
|
208
228
|
"-h": "--help"
|
|
209
229
|
};
|
|
210
|
-
if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.argv[2] === undefined || process.argv.slice(2).every((flag)=>sharedFlags[flag] !== undefined
|
|
211
|
-
))) {
|
|
230
|
+
if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.argv[2] === undefined || process.argv.slice(2).every((flag)=>sharedFlags[flag] !== undefined))) {
|
|
212
231
|
help({
|
|
213
232
|
usage: [
|
|
214
233
|
"tailwindcss [--input input.css] [--output output.css] [--watch] [options...]",
|
|
215
|
-
"tailwindcss init [--full] [--postcss] [
|
|
234
|
+
"tailwindcss init [--full] [--postcss] [options...]",
|
|
216
235
|
],
|
|
217
|
-
commands: Object.keys(commands).filter((command2)=>command2 !== "build"
|
|
218
|
-
).map((command3)=>`${command3} [options]`
|
|
219
|
-
),
|
|
236
|
+
commands: Object.keys(commands).filter((command2)=>command2 !== "build").map((command3)=>`${command3} [options]`),
|
|
220
237
|
options: {
|
|
221
238
|
...commands.build.args,
|
|
222
239
|
...sharedFlags
|
|
@@ -224,8 +241,7 @@ if (process.stdout.isTTY /* Detect redirecting output to a file */ && (process.
|
|
|
224
241
|
});
|
|
225
242
|
process.exit(0);
|
|
226
243
|
}
|
|
227
|
-
let command = ((arg = "")=>arg.startsWith("-") ? undefined : arg
|
|
228
|
-
)(process.argv[2]) || "build";
|
|
244
|
+
let command = ((arg = "")=>arg.startsWith("-") ? undefined : arg)(process.argv[2]) || "build";
|
|
229
245
|
if (commands[command] === undefined) {
|
|
230
246
|
if (_fs.default.existsSync(_path.default.resolve(command))) {
|
|
231
247
|
// TODO: Deprecate this in future versions
|
|
@@ -237,9 +253,7 @@ if (commands[command] === undefined) {
|
|
|
237
253
|
usage: [
|
|
238
254
|
"tailwindcss <command> [options]"
|
|
239
255
|
],
|
|
240
|
-
commands: Object.keys(commands).filter((command4)=>command4 !== "build"
|
|
241
|
-
).map((command5)=>`${command5} [options]`
|
|
242
|
-
),
|
|
256
|
+
commands: Object.keys(commands).filter((command4)=>command4 !== "build").map((command5)=>`${command5} [options]`),
|
|
243
257
|
options: sharedFlags
|
|
244
258
|
});
|
|
245
259
|
process.exit(1);
|
|
@@ -258,8 +272,7 @@ let args = (()=>{
|
|
|
258
272
|
}).map(([key, value])=>[
|
|
259
273
|
key,
|
|
260
274
|
typeof value === "object" ? value.type : value
|
|
261
|
-
]
|
|
262
|
-
)), {
|
|
275
|
+
])), {
|
|
263
276
|
permissive: true
|
|
264
277
|
});
|
|
265
278
|
// Manual parsing of flags to allow for special flags like oneOf(Boolean, String)
|
|
@@ -326,22 +339,18 @@ run();
|
|
|
326
339
|
function init() {
|
|
327
340
|
let messages = [];
|
|
328
341
|
var ref;
|
|
329
|
-
let tailwindConfigLocation = _path.default.resolve((ref = args["_"][1]) !== null && ref !== void 0 ? ref :
|
|
342
|
+
let tailwindConfigLocation = _path.default.resolve((ref = args["_"][1]) !== null && ref !== void 0 ? ref : `./${configs.tailwind}`);
|
|
330
343
|
if (_fs.default.existsSync(tailwindConfigLocation)) {
|
|
331
344
|
messages.push(`${_path.default.basename(tailwindConfigLocation)} already exists.`);
|
|
332
345
|
} else {
|
|
333
346
|
let stubFile = _fs.default.readFileSync(args["--full"] ? _path.default.resolve(__dirname, "../stubs/defaultConfig.stub.js") : _path.default.resolve(__dirname, "../stubs/simpleConfig.stub.js"), "utf8");
|
|
334
|
-
if (args["--types"]) {
|
|
335
|
-
let typesHeading = "/** @type {import('tailwindcss/types').Config} */";
|
|
336
|
-
stubFile = stubFile.replace(`module.exports = `, `${typesHeading}\nconst config = `) + "\nmodule.exports = config";
|
|
337
|
-
}
|
|
338
347
|
// Change colors import
|
|
339
348
|
stubFile = stubFile.replace("../colors", "tailwindcss/colors");
|
|
340
349
|
_fs.default.writeFileSync(tailwindConfigLocation, stubFile, "utf8");
|
|
341
350
|
messages.push(`Created Tailwind CSS config file: ${_path.default.basename(tailwindConfigLocation)}`);
|
|
342
351
|
}
|
|
343
352
|
if (args["--postcss"]) {
|
|
344
|
-
let postcssConfigLocation = _path.default.resolve(
|
|
353
|
+
let postcssConfigLocation = _path.default.resolve(`./${configs.postcss}`);
|
|
345
354
|
if (_fs.default.existsSync(postcssConfigLocation)) {
|
|
346
355
|
messages.push(`${_path.default.basename(postcssConfigLocation)} already exists.`);
|
|
347
356
|
} else {
|
|
@@ -380,11 +389,10 @@ async function build() {
|
|
|
380
389
|
console.error(`Specified config file ${args["--config"]} does not exist.`);
|
|
381
390
|
process.exit(9);
|
|
382
391
|
}
|
|
383
|
-
let configPath = args["--config"] ? args["--config"] : ((defaultPath)=>_fs.default.existsSync(defaultPath) ? defaultPath : null
|
|
384
|
-
)(_path.default.resolve("./tailwind.config.js"));
|
|
392
|
+
let configPath = args["--config"] ? args["--config"] : ((defaultPath)=>_fs.default.existsSync(defaultPath) ? defaultPath : null)(_path.default.resolve(`./${configs.tailwind}`));
|
|
385
393
|
async function loadPostCssPlugins() {
|
|
386
394
|
let customPostCssPath = typeof args["--postcss"] === "string" ? args["--postcss"] : undefined;
|
|
387
|
-
let
|
|
395
|
+
let config1 = customPostCssPath ? await (async ()=>{
|
|
388
396
|
let file = _path.default.resolve(customPostCssPath);
|
|
389
397
|
// Implementation, see: https://unpkg.com/browse/postcss-load-config@3.1.0/src/index.js
|
|
390
398
|
let { config ={} } = await (0, _lilconfig).lilconfig("postcss").load(file);
|
|
@@ -397,9 +405,12 @@ async function build() {
|
|
|
397
405
|
config.plugins = [];
|
|
398
406
|
}
|
|
399
407
|
return {
|
|
400
|
-
|
|
408
|
+
file,
|
|
409
|
+
plugins: (0, _plugins).default(config, file),
|
|
410
|
+
options: (0, _options).default(config, file)
|
|
401
411
|
};
|
|
402
412
|
})() : await (0, _postcssLoadConfig).default();
|
|
413
|
+
let configPlugins = config1.plugins;
|
|
403
414
|
let configPluginTailwindIdx = configPlugins.findIndex((plugin)=>{
|
|
404
415
|
if (typeof plugin === "function" && plugin.name === "tailwindcss") {
|
|
405
416
|
return true;
|
|
@@ -413,7 +424,45 @@ async function build() {
|
|
|
413
424
|
let afterPlugins = configPluginTailwindIdx === -1 ? configPlugins : configPlugins.slice(configPluginTailwindIdx + 1);
|
|
414
425
|
return [
|
|
415
426
|
beforePlugins,
|
|
416
|
-
afterPlugins
|
|
427
|
+
afterPlugins,
|
|
428
|
+
config1.options
|
|
429
|
+
];
|
|
430
|
+
}
|
|
431
|
+
function loadBuiltinPostcssPlugins() {
|
|
432
|
+
let postcss = loadPostcss();
|
|
433
|
+
let IMPORT_COMMENT = "__TAILWIND_RESTORE_IMPORT__: ";
|
|
434
|
+
return [
|
|
435
|
+
[
|
|
436
|
+
(root)=>{
|
|
437
|
+
root.walkAtRules("import", (rule)=>{
|
|
438
|
+
if (rule.params.slice(1).startsWith("tailwindcss/")) {
|
|
439
|
+
rule.after(postcss.comment({
|
|
440
|
+
text: IMPORT_COMMENT + rule.params
|
|
441
|
+
}));
|
|
442
|
+
rule.remove();
|
|
443
|
+
}
|
|
444
|
+
});
|
|
445
|
+
},
|
|
446
|
+
(()=>{
|
|
447
|
+
try {
|
|
448
|
+
return require("postcss-import");
|
|
449
|
+
} catch {}
|
|
450
|
+
return (0, _indexJs).lazyPostcssImport();
|
|
451
|
+
})(),
|
|
452
|
+
(root)=>{
|
|
453
|
+
root.walkComments((rule)=>{
|
|
454
|
+
if (rule.text.startsWith(IMPORT_COMMENT)) {
|
|
455
|
+
rule.after(postcss.atRule({
|
|
456
|
+
name: "import",
|
|
457
|
+
params: rule.text.replace(IMPORT_COMMENT, "")
|
|
458
|
+
}));
|
|
459
|
+
rule.remove();
|
|
460
|
+
}
|
|
461
|
+
});
|
|
462
|
+
},
|
|
463
|
+
],
|
|
464
|
+
[],
|
|
465
|
+
{},
|
|
417
466
|
];
|
|
418
467
|
}
|
|
419
468
|
function resolveConfig() {
|
|
@@ -435,9 +484,12 @@ async function build() {
|
|
|
435
484
|
}
|
|
436
485
|
});
|
|
437
486
|
resolvedConfig.content.files = files;
|
|
487
|
+
resolvedConfig = (0, _validateConfigJs).validateConfig(resolvedConfig);
|
|
438
488
|
return resolvedConfig;
|
|
439
489
|
}
|
|
440
|
-
|
|
490
|
+
let resolvedConfig = (0, _resolveConfig).default(config);
|
|
491
|
+
resolvedConfig = (0, _validateConfigJs).validateConfig(resolvedConfig);
|
|
492
|
+
return resolvedConfig;
|
|
441
493
|
}
|
|
442
494
|
function extractFileGlobs(config) {
|
|
443
495
|
return config.content.files.filter((file)=>{
|
|
@@ -445,8 +497,7 @@ async function build() {
|
|
|
445
497
|
// like an object it's probably a raw content object. But this object
|
|
446
498
|
// is not watchable, so let's remove it.
|
|
447
499
|
return typeof file === "string";
|
|
448
|
-
}).map((glob)=>(0, _normalizePath).default(glob)
|
|
449
|
-
);
|
|
500
|
+
}).map((glob)=>(0, _normalizePath).default(glob));
|
|
450
501
|
}
|
|
451
502
|
function extractRawContent(config) {
|
|
452
503
|
return config.content.files.filter((file)=>{
|
|
@@ -489,10 +540,7 @@ async function build() {
|
|
|
489
540
|
};
|
|
490
541
|
};
|
|
491
542
|
tailwindPlugin.postcss = true;
|
|
492
|
-
let [beforePlugins, afterPlugins] = includePostCss ? await loadPostCssPlugins() :
|
|
493
|
-
[],
|
|
494
|
-
[]
|
|
495
|
-
];
|
|
543
|
+
let [beforePlugins, afterPlugins, postcssOptions] = includePostCss ? await loadPostCssPlugins() : loadBuiltinPostcssPlugins();
|
|
496
544
|
let plugins = [
|
|
497
545
|
...beforePlugins,
|
|
498
546
|
tailwindPlugin,
|
|
@@ -521,17 +569,17 @@ async function build() {
|
|
|
521
569
|
return (0, _indexJs).lazyCssnano()(options);
|
|
522
570
|
})(),
|
|
523
571
|
].filter(Boolean);
|
|
524
|
-
let
|
|
572
|
+
let postcss = loadPostcss();
|
|
573
|
+
let processor = postcss(plugins);
|
|
525
574
|
function processCSS(css) {
|
|
526
575
|
let start = process.hrtime.bigint();
|
|
527
576
|
return Promise.resolve().then(()=>output ? _fs.default.promises.mkdir(_path.default.dirname(output), {
|
|
528
577
|
recursive: true
|
|
529
|
-
}) : null
|
|
530
|
-
|
|
578
|
+
}) : null).then(()=>processor.process(css, {
|
|
579
|
+
...postcssOptions,
|
|
531
580
|
from: input,
|
|
532
581
|
to: output
|
|
533
|
-
})
|
|
534
|
-
).then((result)=>{
|
|
582
|
+
})).then((result)=>{
|
|
535
583
|
if (!output) {
|
|
536
584
|
return process.stdout.write(result.css);
|
|
537
585
|
}
|
|
@@ -542,7 +590,7 @@ async function build() {
|
|
|
542
590
|
}).then(()=>{
|
|
543
591
|
let end = process.hrtime.bigint();
|
|
544
592
|
console.error();
|
|
545
|
-
console.error("Done in", (end - start) / BigInt(
|
|
593
|
+
console.error("Done in", (end - start) / BigInt(1e6) + "ms.");
|
|
546
594
|
});
|
|
547
595
|
}
|
|
548
596
|
let css1 = await (()=>{
|
|
@@ -571,8 +619,7 @@ async function build() {
|
|
|
571
619
|
delete require.cache[require.resolve(file1)];
|
|
572
620
|
}
|
|
573
621
|
if (configPath) {
|
|
574
|
-
configDependencies = (0, _getModuleDependencies).default(configPath).map(({ file })=>file
|
|
575
|
-
);
|
|
622
|
+
configDependencies = (0, _getModuleDependencies).default(configPath).map(({ file })=>file);
|
|
576
623
|
for (let dependency of configDependencies){
|
|
577
624
|
contextDependencies.add(dependency);
|
|
578
625
|
}
|
|
@@ -580,10 +627,7 @@ async function build() {
|
|
|
580
627
|
env.DEBUG && console.timeEnd("Module dependencies");
|
|
581
628
|
return resolveConfig();
|
|
582
629
|
}
|
|
583
|
-
let [beforePlugins, afterPlugins] = includePostCss ? await loadPostCssPlugins() :
|
|
584
|
-
[],
|
|
585
|
-
[]
|
|
586
|
-
];
|
|
630
|
+
let [beforePlugins, afterPlugins] = includePostCss ? await loadPostCssPlugins() : loadBuiltinPostcssPlugins();
|
|
587
631
|
let plugins = [
|
|
588
632
|
...beforePlugins,
|
|
589
633
|
"__TAILWIND_PLUGIN_POSITION__",
|
|
@@ -641,17 +685,16 @@ async function build() {
|
|
|
641
685
|
let tailwindPluginIdx = plugins.indexOf("__TAILWIND_PLUGIN_POSITION__");
|
|
642
686
|
let copy = plugins.slice();
|
|
643
687
|
copy.splice(tailwindPluginIdx, 1, tailwindPlugin);
|
|
644
|
-
let
|
|
688
|
+
let postcss = loadPostcss();
|
|
689
|
+
let processor = postcss(copy);
|
|
645
690
|
function processCSS(css) {
|
|
646
691
|
let start = process.hrtime.bigint();
|
|
647
692
|
return Promise.resolve().then(()=>output ? _fs.default.promises.mkdir(_path.default.dirname(output), {
|
|
648
693
|
recursive: true
|
|
649
|
-
}) : null
|
|
650
|
-
).then(()=>processor.process(css, {
|
|
694
|
+
}) : null).then(()=>processor.process(css, {
|
|
651
695
|
from: input,
|
|
652
696
|
to: output
|
|
653
|
-
})
|
|
654
|
-
).then(async (result)=>{
|
|
697
|
+
})).then(async (result)=>{
|
|
655
698
|
for (let message of result.messages){
|
|
656
699
|
if (message.type === "dependency") {
|
|
657
700
|
contextDependencies.add(message.file);
|
|
@@ -669,7 +712,7 @@ async function build() {
|
|
|
669
712
|
].filter(Boolean));
|
|
670
713
|
}).then(()=>{
|
|
671
714
|
let end = process.hrtime.bigint();
|
|
672
|
-
console.error("Done in", (end - start) / BigInt(
|
|
715
|
+
console.error("Done in", (end - start) / BigInt(1e6) + "ms.");
|
|
673
716
|
}).catch((err)=>{
|
|
674
717
|
if (err.name === "CssSyntaxError") {
|
|
675
718
|
console.error(err.toString());
|
|
@@ -694,13 +737,13 @@ async function build() {
|
|
|
694
737
|
env.DEBUG && console.timeEnd("Finished in");
|
|
695
738
|
return result1;
|
|
696
739
|
}
|
|
697
|
-
let
|
|
740
|
+
let config2 = refreshConfig(configPath);
|
|
698
741
|
if (input) {
|
|
699
742
|
contextDependencies.add(_path.default.resolve(input));
|
|
700
743
|
}
|
|
701
744
|
watcher = _chokidar.default.watch([
|
|
702
745
|
...contextDependencies,
|
|
703
|
-
...extractFileGlobs(
|
|
746
|
+
...extractFileGlobs(config2)
|
|
704
747
|
], {
|
|
705
748
|
usePolling: shouldPoll,
|
|
706
749
|
interval: shouldPoll ? pollInterval : undefined,
|
|
@@ -715,16 +758,16 @@ async function build() {
|
|
|
715
758
|
if (contextDependencies.has(file)) {
|
|
716
759
|
env.DEBUG && console.time("Resolve config");
|
|
717
760
|
context = null;
|
|
718
|
-
|
|
761
|
+
config2 = refreshConfig(configPath);
|
|
719
762
|
env.DEBUG && console.timeEnd("Resolve config");
|
|
720
763
|
env.DEBUG && console.time("Watch new files");
|
|
721
|
-
let globs = extractFileGlobs(
|
|
764
|
+
let globs = extractFileGlobs(config2);
|
|
722
765
|
watcher.add(configDependencies);
|
|
723
766
|
watcher.add(globs);
|
|
724
767
|
env.DEBUG && console.timeEnd("Watch new files");
|
|
725
768
|
chain = chain.then(async ()=>{
|
|
726
|
-
changedContent.push(...getChangedContent(
|
|
727
|
-
await rebuild(
|
|
769
|
+
changedContent.push(...getChangedContent(config2));
|
|
770
|
+
await rebuild(config2);
|
|
728
771
|
});
|
|
729
772
|
} else {
|
|
730
773
|
chain = chain.then(async ()=>{
|
|
@@ -732,7 +775,7 @@ async function build() {
|
|
|
732
775
|
content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
|
|
733
776
|
extension: _path.default.extname(file).slice(1)
|
|
734
777
|
});
|
|
735
|
-
await rebuild(
|
|
778
|
+
await rebuild(config2);
|
|
736
779
|
});
|
|
737
780
|
}
|
|
738
781
|
});
|
|
@@ -742,18 +785,19 @@ async function build() {
|
|
|
742
785
|
content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
|
|
743
786
|
extension: _path.default.extname(file).slice(1)
|
|
744
787
|
});
|
|
745
|
-
await rebuild(
|
|
788
|
+
await rebuild(config2);
|
|
746
789
|
});
|
|
747
790
|
});
|
|
748
791
|
chain = chain.then(()=>{
|
|
749
|
-
changedContent.push(...getChangedContent(
|
|
750
|
-
return rebuild(
|
|
792
|
+
changedContent.push(...getChangedContent(config2));
|
|
793
|
+
return rebuild(config2);
|
|
751
794
|
});
|
|
752
795
|
}
|
|
753
796
|
if (shouldWatch) {
|
|
754
|
-
/* Abort the watcher if stdin is closed to avoid zombie processes */ process.stdin.
|
|
755
|
-
|
|
756
|
-
|
|
797
|
+
/* Abort the watcher if stdin is closed to avoid zombie processes */ if (process.stdin.isTTY) {
|
|
798
|
+
process.stdin.on("end", ()=>process.exit(0));
|
|
799
|
+
process.stdin.resume();
|
|
800
|
+
}
|
|
757
801
|
startWatcher();
|
|
758
802
|
} else {
|
|
759
803
|
buildOnce();
|