tailwindcss 3.0.24 → 3.1.2
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 +75 -3
- package/colors.d.ts +3 -0
- package/defaultConfig.d.ts +3 -0
- package/defaultTheme.d.ts +3 -0
- package/lib/cli-peer-dependencies.js +8 -3
- package/lib/cli.js +125 -83
- package/lib/corePluginList.js +1 -0
- package/lib/corePlugins.js +146 -117
- package/lib/css/preflight.css +1 -8
- package/lib/featureFlags.js +8 -6
- package/lib/index.js +10 -13
- package/lib/lib/cacheInvalidation.js +32 -14
- package/lib/lib/collapseAdjacentRules.js +5 -3
- package/lib/lib/defaultExtractor.js +191 -32
- package/lib/lib/evaluateTailwindFunctions.js +22 -13
- package/lib/lib/expandApplyAtRules.js +232 -195
- package/lib/lib/expandTailwindAtRules.js +40 -26
- package/lib/lib/generateRules.js +106 -42
- package/lib/lib/regex.js +52 -0
- package/lib/lib/resolveDefaultsAtRules.js +56 -45
- package/lib/lib/setupContextUtils.js +131 -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 +14 -12
- package/lib/util/flattenColorPalette.js +2 -5
- package/lib/util/formatVariantSelector.js +64 -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/resolveConfig.js +57 -34
- 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 +21 -16
- package/peers/index.js +3264 -1330
- package/plugin.d.ts +11 -0
- package/src/cli-peer-dependencies.js +7 -1
- package/src/cli.js +104 -34
- package/src/corePluginList.js +1 -1
- package/src/corePlugins.js +57 -40
- package/src/css/preflight.css +1 -8
- package/src/featureFlags.js +2 -2
- package/src/index.js +0 -2
- package/src/lib/collapseAdjacentRules.js +5 -1
- package/src/lib/defaultExtractor.js +177 -35
- package/src/lib/evaluateTailwindFunctions.js +20 -4
- package/src/lib/expandApplyAtRules.js +247 -188
- package/src/lib/expandTailwindAtRules.js +4 -4
- package/src/lib/generateRules.js +69 -5
- package/src/lib/regex.js +74 -0
- package/src/lib/resolveDefaultsAtRules.js +53 -36
- package/src/lib/setupContextUtils.js +103 -39
- package/src/lib/setupTrackingContext.js +4 -0
- package/src/util/color.js +20 -18
- package/src/util/dataTypes.js +11 -5
- package/src/util/formatVariantSelector.js +79 -62
- 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/resolveConfig.js +66 -54
- 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 -3
- package/stubs/simpleConfig.stub.js +1 -0
- package/types/config.d.ts +325 -0
- package/types/generated/.gitkeep +0 -0
- package/types/generated/colors.d.ts +276 -0
- package/types/generated/corePluginList.d.ts +1 -0
- package/types/index.d.ts +7 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,9 +7,77 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
-
Nothing yet!
|
|
10
|
+
- Nothing yet!
|
|
11
11
|
|
|
12
|
-
## [3.
|
|
12
|
+
## [3.1.2] - 2022-06-10
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- Ensure `\` is a valid arbitrary variant token ([#8576](https://github.com/tailwindlabs/tailwindcss/pull/8576))
|
|
17
|
+
- 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))
|
|
18
|
+
|
|
19
|
+
## [3.1.1] - 2022-06-09
|
|
20
|
+
|
|
21
|
+
### Fixed
|
|
22
|
+
|
|
23
|
+
- Fix candidate extractor regression ([#8558](https://github.com/tailwindlabs/tailwindcss/pull/8558))
|
|
24
|
+
- Split `::backdrop` into separate defaults group ([#8567](https://github.com/tailwindlabs/tailwindcss/pull/8567))
|
|
25
|
+
- Fix postcss plugin type ([#8564](https://github.com/tailwindlabs/tailwindcss/pull/8564))
|
|
26
|
+
- Fix class detection in markdown code fences and slim templates ([#8569](https://github.com/tailwindlabs/tailwindcss/pull/8569))
|
|
27
|
+
|
|
28
|
+
## [3.1.0] - 2022-06-08
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- Types: allow for arbitrary theme values (for 3rd party plugins) ([#7926](https://github.com/tailwindlabs/tailwindcss/pull/7926))
|
|
33
|
+
- Don’t split vars with numbers in them inside arbitrary values ([#8091](https://github.com/tailwindlabs/tailwindcss/pull/8091))
|
|
34
|
+
- Require matching prefix when detecting negatives ([#8121](https://github.com/tailwindlabs/tailwindcss/pull/8121))
|
|
35
|
+
- Handle duplicate At Rules without children ([#8122](https://github.com/tailwindlabs/tailwindcss/pull/8122))
|
|
36
|
+
- Allow arbitrary values with commas in `@apply` ([#8125](https://github.com/tailwindlabs/tailwindcss/pull/8125))
|
|
37
|
+
- Fix intellisense for plugins with multiple `@apply` rules ([#8213](https://github.com/tailwindlabs/tailwindcss/pull/8213))
|
|
38
|
+
- Improve type detection for arbitrary color values ([#8201](https://github.com/tailwindlabs/tailwindcss/pull/8201))
|
|
39
|
+
- Support PostCSS config options in config file in CLI ([#8226](https://github.com/tailwindlabs/tailwindcss/pull/8226))
|
|
40
|
+
- Remove default `[hidden]` style in preflight ([#8248](https://github.com/tailwindlabs/tailwindcss/pull/8248))
|
|
41
|
+
- Only check selectors containing base apply candidates for circular dependencies ([#8222](https://github.com/tailwindlabs/tailwindcss/pull/8222))
|
|
42
|
+
- Rewrite default class extractor ([#8204](https://github.com/tailwindlabs/tailwindcss/pull/8204))
|
|
43
|
+
- Move `important` selector to the front when `@apply`-ing selector-modifying variants in custom utilities ([#8313](https://github.com/tailwindlabs/tailwindcss/pull/8313))
|
|
44
|
+
- Error when registering an invalid custom variant ([#8345](https://github.com/tailwindlabs/tailwindcss/pull/8345))
|
|
45
|
+
- Create tailwind.config.cjs file in ESM package when running init ([#8363](https://github.com/tailwindlabs/tailwindcss/pull/8363))
|
|
46
|
+
- Fix `matchVariants` that use at-rules and placeholders ([#8392](https://github.com/tailwindlabs/tailwindcss/pull/8392))
|
|
47
|
+
- Improve types of the `tailwindcss/plugin` ([#8400](https://github.com/tailwindlabs/tailwindcss/pull/8400))
|
|
48
|
+
- Allow returning parallel variants from `addVariant` or `matchVariant` callback functions ([#8455](https://github.com/tailwindlabs/tailwindcss/pull/8455))
|
|
49
|
+
- Try using local `postcss` installation first in the CLI ([#8270](https://github.com/tailwindlabs/tailwindcss/pull/8270))
|
|
50
|
+
- Allow default ring color to be a function ([#7587](https://github.com/tailwindlabs/tailwindcss/pull/7587))
|
|
51
|
+
- Don't inherit `to` value from parent gradients ([#8489](https://github.com/tailwindlabs/tailwindcss/pull/8489))
|
|
52
|
+
- Remove process dependency from log functions ([#8530](https://github.com/tailwindlabs/tailwindcss/pull/8530))
|
|
53
|
+
- Ensure we can use `@import 'tailwindcss/...'` without node_modules ([#8537](https://github.com/tailwindlabs/tailwindcss/pull/8537))
|
|
54
|
+
|
|
55
|
+
### Changed
|
|
56
|
+
|
|
57
|
+
- Only apply hover styles when supported (future) ([#8394](https://github.com/tailwindlabs/tailwindcss/pull/8394))
|
|
58
|
+
- Respect default ring color opacity (future) ([#8448](https://github.com/tailwindlabs/tailwindcss/pull/8448), [3f4005e](https://github.com/tailwindlabs/tailwindcss/commit/3f4005e833445f7549219eb5ae89728cbb3a2630))
|
|
59
|
+
|
|
60
|
+
### Added
|
|
61
|
+
|
|
62
|
+
- Support PostCSS `Document` nodes ([#7291](https://github.com/tailwindlabs/tailwindcss/pull/7291))
|
|
63
|
+
- Add `text-start` and `text-end` utilities ([#6656](https://github.com/tailwindlabs/tailwindcss/pull/6656))
|
|
64
|
+
- Support customizing class name when using `darkMode: 'class'` ([#5800](https://github.com/tailwindlabs/tailwindcss/pull/5800))
|
|
65
|
+
- Add `--poll` option to the CLI ([#7725](https://github.com/tailwindlabs/tailwindcss/pull/7725))
|
|
66
|
+
- Add new `border-spacing` utilities ([#7102](https://github.com/tailwindlabs/tailwindcss/pull/7102))
|
|
67
|
+
- Add `enabled` variant ([#7905](https://github.com/tailwindlabs/tailwindcss/pull/7905))
|
|
68
|
+
- Add TypeScript types for the `tailwind.config.js` file ([#7891](https://github.com/tailwindlabs/tailwindcss/pull/7891))
|
|
69
|
+
- Add `backdrop` variant ([#7924](https://github.com/tailwindlabs/tailwindcss/pull/7924), [#8526](https://github.com/tailwindlabs/tailwindcss/pull/8526))
|
|
70
|
+
- Add `grid-flow-dense` utility ([#8193](https://github.com/tailwindlabs/tailwindcss/pull/8193))
|
|
71
|
+
- Add `mix-blend-plus-lighter` utility ([#8288](https://github.com/tailwindlabs/tailwindcss/pull/8288))
|
|
72
|
+
- Add arbitrary variants ([#8299](https://github.com/tailwindlabs/tailwindcss/pull/8299))
|
|
73
|
+
- Add experimental `matchVariant` API ([#8310](https://github.com/tailwindlabs/tailwindcss/pull/8310), [34fd0fb8](https://github.com/tailwindlabs/tailwindcss/commit/34fd0fb82aa574cddc5c7aa3ad7d1af5e3735e5d))
|
|
74
|
+
- Add `prefers-contrast` media query variants ([#8410](https://github.com/tailwindlabs/tailwindcss/pull/8410))
|
|
75
|
+
- Add opacity support when referencing colors with `theme` function ([#8416](https://github.com/tailwindlabs/tailwindcss/pull/8416))
|
|
76
|
+
- Add `postcss-import` support to the CLI ([#8437](https://github.com/tailwindlabs/tailwindcss/pull/8437))
|
|
77
|
+
- Add `optional` variant ([#8486](https://github.com/tailwindlabs/tailwindcss/pull/8486))
|
|
78
|
+
- Add `<alpha-value>` placeholder support for custom colors ([#8501](https://github.com/tailwindlabs/tailwindcss/pull/8501))
|
|
79
|
+
|
|
80
|
+
## [3.0.24] - 2022-04-12
|
|
13
81
|
|
|
14
82
|
### Fixed
|
|
15
83
|
|
|
@@ -27,6 +95,7 @@ Nothing yet!
|
|
|
27
95
|
- Allow for custom properties in `rgb`, `rgba`, `hsl` and `hsla` colors ([#7933](https://github.com/tailwindlabs/tailwindcss/pull/7933))
|
|
28
96
|
- Remove autoprefixer as explicit peer-dependency to avoid invalid warnings in situations where it isn't actually needed ([#7949](https://github.com/tailwindlabs/tailwindcss/pull/7949))
|
|
29
97
|
- Ensure the `percentage` data type is validated correctly ([#8015](https://github.com/tailwindlabs/tailwindcss/pull/8015))
|
|
98
|
+
- Make sure `font-weight` is inherited by form controls in all browsers ([#8078](https://github.com/tailwindlabs/tailwindcss/pull/8078))
|
|
30
99
|
|
|
31
100
|
### Changed
|
|
32
101
|
|
|
@@ -1899,7 +1968,10 @@ No release notes
|
|
|
1899
1968
|
|
|
1900
1969
|
- Everything!
|
|
1901
1970
|
|
|
1902
|
-
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.
|
|
1971
|
+
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.2...HEAD
|
|
1972
|
+
[3.1.2]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.1...v3.1.2
|
|
1973
|
+
[3.1.1]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.0...v3.1.1
|
|
1974
|
+
[3.1.0]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.24...v3.1.0
|
|
1903
1975
|
[3.0.24]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.23...v3.0.24
|
|
1904
1976
|
[3.0.23]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.22...v3.0.23
|
|
1905
1977
|
[3.0.22]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.21...v3.0.22
|
package/colors.d.ts
ADDED
|
@@ -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"
|
|
@@ -163,12 +183,11 @@ let commands = {
|
|
|
163
183
|
type: Boolean,
|
|
164
184
|
description: "Watch for changes and rebuild as needed"
|
|
165
185
|
},
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
*/ "--content": {
|
|
186
|
+
"--poll": {
|
|
187
|
+
type: Boolean,
|
|
188
|
+
description: "Use polling instead of filesystem events when watching"
|
|
189
|
+
},
|
|
190
|
+
"--content": {
|
|
172
191
|
type: String,
|
|
173
192
|
description: "Content paths to use for removing unused classes"
|
|
174
193
|
},
|
|
@@ -196,7 +215,8 @@ let commands = {
|
|
|
196
215
|
"-i": "--input",
|
|
197
216
|
"-o": "--output",
|
|
198
217
|
"-m": "--minify",
|
|
199
|
-
"-w": "--watch"
|
|
218
|
+
"-w": "--watch",
|
|
219
|
+
"-p": "--poll"
|
|
200
220
|
}
|
|
201
221
|
}
|
|
202
222
|
};
|
|
@@ -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 {
|
|
@@ -361,10 +370,8 @@ async function build() {
|
|
|
361
370
|
let input = args["--input"];
|
|
362
371
|
let output = args["--output"];
|
|
363
372
|
let shouldWatch = args["--watch"];
|
|
364
|
-
let shouldPoll =
|
|
365
|
-
|
|
366
|
-
let shouldPoll = args['--poll']
|
|
367
|
-
*/ let shouldCoalesceWriteEvents = shouldPoll || process.platform === "win32";
|
|
373
|
+
let shouldPoll = args["--poll"];
|
|
374
|
+
let shouldCoalesceWriteEvents = shouldPoll || process.platform === "win32";
|
|
368
375
|
let includePostCss = args["--postcss"];
|
|
369
376
|
// Polling interval in milliseconds
|
|
370
377
|
// Used only when polling or coalescing add/change events on Windows
|
|
@@ -382,11 +389,10 @@ async function build() {
|
|
|
382
389
|
console.error(`Specified config file ${args["--config"]} does not exist.`);
|
|
383
390
|
process.exit(9);
|
|
384
391
|
}
|
|
385
|
-
let configPath = args["--config"] ? args["--config"] : ((defaultPath)=>_fs.default.existsSync(defaultPath) ? defaultPath : null
|
|
386
|
-
)(_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}`));
|
|
387
393
|
async function loadPostCssPlugins() {
|
|
388
394
|
let customPostCssPath = typeof args["--postcss"] === "string" ? args["--postcss"] : undefined;
|
|
389
|
-
let
|
|
395
|
+
let config1 = customPostCssPath ? await (async ()=>{
|
|
390
396
|
let file = _path.default.resolve(customPostCssPath);
|
|
391
397
|
// Implementation, see: https://unpkg.com/browse/postcss-load-config@3.1.0/src/index.js
|
|
392
398
|
let { config ={} } = await (0, _lilconfig).lilconfig("postcss").load(file);
|
|
@@ -399,9 +405,12 @@ async function build() {
|
|
|
399
405
|
config.plugins = [];
|
|
400
406
|
}
|
|
401
407
|
return {
|
|
402
|
-
|
|
408
|
+
file,
|
|
409
|
+
plugins: (0, _plugins).default(config, file),
|
|
410
|
+
options: (0, _options).default(config, file)
|
|
403
411
|
};
|
|
404
412
|
})() : await (0, _postcssLoadConfig).default();
|
|
413
|
+
let configPlugins = config1.plugins;
|
|
405
414
|
let configPluginTailwindIdx = configPlugins.findIndex((plugin)=>{
|
|
406
415
|
if (typeof plugin === "function" && plugin.name === "tailwindcss") {
|
|
407
416
|
return true;
|
|
@@ -415,7 +424,45 @@ async function build() {
|
|
|
415
424
|
let afterPlugins = configPluginTailwindIdx === -1 ? configPlugins : configPlugins.slice(configPluginTailwindIdx + 1);
|
|
416
425
|
return [
|
|
417
426
|
beforePlugins,
|
|
418
|
-
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
|
+
{},
|
|
419
466
|
];
|
|
420
467
|
}
|
|
421
468
|
function resolveConfig() {
|
|
@@ -437,9 +484,12 @@ async function build() {
|
|
|
437
484
|
}
|
|
438
485
|
});
|
|
439
486
|
resolvedConfig.content.files = files;
|
|
487
|
+
resolvedConfig = (0, _validateConfigJs).validateConfig(resolvedConfig);
|
|
440
488
|
return resolvedConfig;
|
|
441
489
|
}
|
|
442
|
-
|
|
490
|
+
let resolvedConfig = (0, _resolveConfig).default(config);
|
|
491
|
+
resolvedConfig = (0, _validateConfigJs).validateConfig(resolvedConfig);
|
|
492
|
+
return resolvedConfig;
|
|
443
493
|
}
|
|
444
494
|
function extractFileGlobs(config) {
|
|
445
495
|
return config.content.files.filter((file)=>{
|
|
@@ -447,8 +497,7 @@ async function build() {
|
|
|
447
497
|
// like an object it's probably a raw content object. But this object
|
|
448
498
|
// is not watchable, so let's remove it.
|
|
449
499
|
return typeof file === "string";
|
|
450
|
-
}).map((glob)=>(0, _normalizePath).default(glob)
|
|
451
|
-
);
|
|
500
|
+
}).map((glob)=>(0, _normalizePath).default(glob));
|
|
452
501
|
}
|
|
453
502
|
function extractRawContent(config) {
|
|
454
503
|
return config.content.files.filter((file)=>{
|
|
@@ -491,10 +540,7 @@ async function build() {
|
|
|
491
540
|
};
|
|
492
541
|
};
|
|
493
542
|
tailwindPlugin.postcss = true;
|
|
494
|
-
let [beforePlugins, afterPlugins] = includePostCss ? await loadPostCssPlugins() :
|
|
495
|
-
[],
|
|
496
|
-
[]
|
|
497
|
-
];
|
|
543
|
+
let [beforePlugins, afterPlugins, postcssOptions] = includePostCss ? await loadPostCssPlugins() : loadBuiltinPostcssPlugins();
|
|
498
544
|
let plugins = [
|
|
499
545
|
...beforePlugins,
|
|
500
546
|
tailwindPlugin,
|
|
@@ -523,17 +569,17 @@ async function build() {
|
|
|
523
569
|
return (0, _indexJs).lazyCssnano()(options);
|
|
524
570
|
})(),
|
|
525
571
|
].filter(Boolean);
|
|
526
|
-
let
|
|
572
|
+
let postcss = loadPostcss();
|
|
573
|
+
let processor = postcss(plugins);
|
|
527
574
|
function processCSS(css) {
|
|
528
575
|
let start = process.hrtime.bigint();
|
|
529
576
|
return Promise.resolve().then(()=>output ? _fs.default.promises.mkdir(_path.default.dirname(output), {
|
|
530
577
|
recursive: true
|
|
531
|
-
}) : null
|
|
532
|
-
|
|
578
|
+
}) : null).then(()=>processor.process(css, {
|
|
579
|
+
...postcssOptions,
|
|
533
580
|
from: input,
|
|
534
581
|
to: output
|
|
535
|
-
})
|
|
536
|
-
).then((result)=>{
|
|
582
|
+
})).then((result)=>{
|
|
537
583
|
if (!output) {
|
|
538
584
|
return process.stdout.write(result.css);
|
|
539
585
|
}
|
|
@@ -544,7 +590,7 @@ async function build() {
|
|
|
544
590
|
}).then(()=>{
|
|
545
591
|
let end = process.hrtime.bigint();
|
|
546
592
|
console.error();
|
|
547
|
-
console.error("Done in", (end - start) / BigInt(
|
|
593
|
+
console.error("Done in", (end - start) / BigInt(1e6) + "ms.");
|
|
548
594
|
});
|
|
549
595
|
}
|
|
550
596
|
let css1 = await (()=>{
|
|
@@ -573,8 +619,7 @@ async function build() {
|
|
|
573
619
|
delete require.cache[require.resolve(file1)];
|
|
574
620
|
}
|
|
575
621
|
if (configPath) {
|
|
576
|
-
configDependencies = (0, _getModuleDependencies).default(configPath).map(({ file })=>file
|
|
577
|
-
);
|
|
622
|
+
configDependencies = (0, _getModuleDependencies).default(configPath).map(({ file })=>file);
|
|
578
623
|
for (let dependency of configDependencies){
|
|
579
624
|
contextDependencies.add(dependency);
|
|
580
625
|
}
|
|
@@ -582,10 +627,7 @@ async function build() {
|
|
|
582
627
|
env.DEBUG && console.timeEnd("Module dependencies");
|
|
583
628
|
return resolveConfig();
|
|
584
629
|
}
|
|
585
|
-
let [beforePlugins, afterPlugins] = includePostCss ? await loadPostCssPlugins() :
|
|
586
|
-
[],
|
|
587
|
-
[]
|
|
588
|
-
];
|
|
630
|
+
let [beforePlugins, afterPlugins] = includePostCss ? await loadPostCssPlugins() : loadBuiltinPostcssPlugins();
|
|
589
631
|
let plugins = [
|
|
590
632
|
...beforePlugins,
|
|
591
633
|
"__TAILWIND_PLUGIN_POSITION__",
|
|
@@ -643,17 +685,16 @@ async function build() {
|
|
|
643
685
|
let tailwindPluginIdx = plugins.indexOf("__TAILWIND_PLUGIN_POSITION__");
|
|
644
686
|
let copy = plugins.slice();
|
|
645
687
|
copy.splice(tailwindPluginIdx, 1, tailwindPlugin);
|
|
646
|
-
let
|
|
688
|
+
let postcss = loadPostcss();
|
|
689
|
+
let processor = postcss(copy);
|
|
647
690
|
function processCSS(css) {
|
|
648
691
|
let start = process.hrtime.bigint();
|
|
649
692
|
return Promise.resolve().then(()=>output ? _fs.default.promises.mkdir(_path.default.dirname(output), {
|
|
650
693
|
recursive: true
|
|
651
|
-
}) : null
|
|
652
|
-
).then(()=>processor.process(css, {
|
|
694
|
+
}) : null).then(()=>processor.process(css, {
|
|
653
695
|
from: input,
|
|
654
696
|
to: output
|
|
655
|
-
})
|
|
656
|
-
).then(async (result)=>{
|
|
697
|
+
})).then(async (result)=>{
|
|
657
698
|
for (let message of result.messages){
|
|
658
699
|
if (message.type === "dependency") {
|
|
659
700
|
contextDependencies.add(message.file);
|
|
@@ -671,7 +712,7 @@ async function build() {
|
|
|
671
712
|
].filter(Boolean));
|
|
672
713
|
}).then(()=>{
|
|
673
714
|
let end = process.hrtime.bigint();
|
|
674
|
-
console.error("Done in", (end - start) / BigInt(
|
|
715
|
+
console.error("Done in", (end - start) / BigInt(1e6) + "ms.");
|
|
675
716
|
}).catch((err)=>{
|
|
676
717
|
if (err.name === "CssSyntaxError") {
|
|
677
718
|
console.error(err.toString());
|
|
@@ -696,13 +737,13 @@ async function build() {
|
|
|
696
737
|
env.DEBUG && console.timeEnd("Finished in");
|
|
697
738
|
return result1;
|
|
698
739
|
}
|
|
699
|
-
let
|
|
740
|
+
let config2 = refreshConfig(configPath);
|
|
700
741
|
if (input) {
|
|
701
742
|
contextDependencies.add(_path.default.resolve(input));
|
|
702
743
|
}
|
|
703
744
|
watcher = _chokidar.default.watch([
|
|
704
745
|
...contextDependencies,
|
|
705
|
-
...extractFileGlobs(
|
|
746
|
+
...extractFileGlobs(config2)
|
|
706
747
|
], {
|
|
707
748
|
usePolling: shouldPoll,
|
|
708
749
|
interval: shouldPoll ? pollInterval : undefined,
|
|
@@ -717,16 +758,16 @@ async function build() {
|
|
|
717
758
|
if (contextDependencies.has(file)) {
|
|
718
759
|
env.DEBUG && console.time("Resolve config");
|
|
719
760
|
context = null;
|
|
720
|
-
|
|
761
|
+
config2 = refreshConfig(configPath);
|
|
721
762
|
env.DEBUG && console.timeEnd("Resolve config");
|
|
722
763
|
env.DEBUG && console.time("Watch new files");
|
|
723
|
-
let globs = extractFileGlobs(
|
|
764
|
+
let globs = extractFileGlobs(config2);
|
|
724
765
|
watcher.add(configDependencies);
|
|
725
766
|
watcher.add(globs);
|
|
726
767
|
env.DEBUG && console.timeEnd("Watch new files");
|
|
727
768
|
chain = chain.then(async ()=>{
|
|
728
|
-
changedContent.push(...getChangedContent(
|
|
729
|
-
await rebuild(
|
|
769
|
+
changedContent.push(...getChangedContent(config2));
|
|
770
|
+
await rebuild(config2);
|
|
730
771
|
});
|
|
731
772
|
} else {
|
|
732
773
|
chain = chain.then(async ()=>{
|
|
@@ -734,7 +775,7 @@ async function build() {
|
|
|
734
775
|
content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
|
|
735
776
|
extension: _path.default.extname(file).slice(1)
|
|
736
777
|
});
|
|
737
|
-
await rebuild(
|
|
778
|
+
await rebuild(config2);
|
|
738
779
|
});
|
|
739
780
|
}
|
|
740
781
|
});
|
|
@@ -744,18 +785,19 @@ async function build() {
|
|
|
744
785
|
content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
|
|
745
786
|
extension: _path.default.extname(file).slice(1)
|
|
746
787
|
});
|
|
747
|
-
await rebuild(
|
|
788
|
+
await rebuild(config2);
|
|
748
789
|
});
|
|
749
790
|
});
|
|
750
791
|
chain = chain.then(()=>{
|
|
751
|
-
changedContent.push(...getChangedContent(
|
|
752
|
-
return rebuild(
|
|
792
|
+
changedContent.push(...getChangedContent(config2));
|
|
793
|
+
return rebuild(config2);
|
|
753
794
|
});
|
|
754
795
|
}
|
|
755
796
|
if (shouldWatch) {
|
|
756
|
-
/* Abort the watcher if stdin is closed to avoid zombie processes */ process.stdin.
|
|
757
|
-
|
|
758
|
-
|
|
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
|
+
}
|
|
759
801
|
startWatcher();
|
|
760
802
|
} else {
|
|
761
803
|
buildOnce();
|