tailwindcss 3.0.24 → 3.1.0
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 +57 -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 +118 -77
- 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 +6 -9
- 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 +97 -33
- 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 +1 -1
- 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 +1 -0
package/CHANGELOG.md
CHANGED
|
@@ -7,9 +7,61 @@ 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.0
|
|
12
|
+
## [3.1.0] - 2022-06-08
|
|
13
|
+
|
|
14
|
+
### Fixed
|
|
15
|
+
|
|
16
|
+
- Types: allow for arbitrary theme values (for 3rd party plugins) ([#7926](https://github.com/tailwindlabs/tailwindcss/pull/7926))
|
|
17
|
+
- Don’t split vars with numbers in them inside arbitrary values ([#8091](https://github.com/tailwindlabs/tailwindcss/pull/8091))
|
|
18
|
+
- Require matching prefix when detecting negatives ([#8121](https://github.com/tailwindlabs/tailwindcss/pull/8121))
|
|
19
|
+
- Handle duplicate At Rules without children ([#8122](https://github.com/tailwindlabs/tailwindcss/pull/8122))
|
|
20
|
+
- Allow arbitrary values with commas in `@apply` ([#8125](https://github.com/tailwindlabs/tailwindcss/pull/8125))
|
|
21
|
+
- Fix intellisense for plugins with multiple `@apply` rules ([#8213](https://github.com/tailwindlabs/tailwindcss/pull/8213))
|
|
22
|
+
- Improve type detection for arbitrary color values ([#8201](https://github.com/tailwindlabs/tailwindcss/pull/8201))
|
|
23
|
+
- Support PostCSS config options in config file in CLI ([#8226](https://github.com/tailwindlabs/tailwindcss/pull/8226))
|
|
24
|
+
- Remove default `[hidden]` style in preflight ([#8248](https://github.com/tailwindlabs/tailwindcss/pull/8248))
|
|
25
|
+
- Only check selectors containing base apply candidates for circular dependencies ([#8222](https://github.com/tailwindlabs/tailwindcss/pull/8222))
|
|
26
|
+
- Rewrite default class extractor ([#8204](https://github.com/tailwindlabs/tailwindcss/pull/8204))
|
|
27
|
+
- Move `important` selector to the front when `@apply`-ing selector-modifying variants in custom utilities ([#8313](https://github.com/tailwindlabs/tailwindcss/pull/8313))
|
|
28
|
+
- Error when registering an invalid custom variant ([#8345](https://github.com/tailwindlabs/tailwindcss/pull/8345))
|
|
29
|
+
- Create tailwind.config.cjs file in ESM package when running init ([#8363](https://github.com/tailwindlabs/tailwindcss/pull/8363))
|
|
30
|
+
- Fix `matchVariants` that use at-rules and placeholders ([#8392](https://github.com/tailwindlabs/tailwindcss/pull/8392))
|
|
31
|
+
- Improve types of the `tailwindcss/plugin` ([#8400](https://github.com/tailwindlabs/tailwindcss/pull/8400))
|
|
32
|
+
- Allow returning parallel variants from `addVariant` or `matchVariant` callback functions ([#8455](https://github.com/tailwindlabs/tailwindcss/pull/8455))
|
|
33
|
+
- Try using local `postcss` installation first in the CLI ([#8270](https://github.com/tailwindlabs/tailwindcss/pull/8270))
|
|
34
|
+
- Allow default ring color to be a function ([#7587](https://github.com/tailwindlabs/tailwindcss/pull/7587))
|
|
35
|
+
- Don't inherit `to` value from parent gradients ([#8489](https://github.com/tailwindlabs/tailwindcss/pull/8489))
|
|
36
|
+
- Remove process dependency from log functions ([#8530](https://github.com/tailwindlabs/tailwindcss/pull/8530))
|
|
37
|
+
- Ensure we can use `@import 'tailwindcss/...'` without node_modules ([#8537](https://github.com/tailwindlabs/tailwindcss/pull/8537))
|
|
38
|
+
|
|
39
|
+
### Changed
|
|
40
|
+
|
|
41
|
+
- Only apply hover styles when supported (future) ([#8394](https://github.com/tailwindlabs/tailwindcss/pull/8394))
|
|
42
|
+
- Respect default ring color opacity (future) ([#8448](https://github.com/tailwindlabs/tailwindcss/pull/8448), [3f4005e](https://github.com/tailwindlabs/tailwindcss/commit/3f4005e833445f7549219eb5ae89728cbb3a2630))
|
|
43
|
+
|
|
44
|
+
### Added
|
|
45
|
+
|
|
46
|
+
- Support PostCSS `Document` nodes ([#7291](https://github.com/tailwindlabs/tailwindcss/pull/7291))
|
|
47
|
+
- Add `text-start` and `text-end` utilities ([#6656](https://github.com/tailwindlabs/tailwindcss/pull/6656))
|
|
48
|
+
- Support customizing class name when using `darkMode: 'class'` ([#5800](https://github.com/tailwindlabs/tailwindcss/pull/5800))
|
|
49
|
+
- Add `--poll` option to the CLI ([#7725](https://github.com/tailwindlabs/tailwindcss/pull/7725))
|
|
50
|
+
- Add new `border-spacing` utilities ([#7102](https://github.com/tailwindlabs/tailwindcss/pull/7102))
|
|
51
|
+
- Add `enabled` variant ([#7905](https://github.com/tailwindlabs/tailwindcss/pull/7905))
|
|
52
|
+
- Add TypeScript types for the `tailwind.config.js` file ([#7891](https://github.com/tailwindlabs/tailwindcss/pull/7891))
|
|
53
|
+
- Add `backdrop` variant ([#7924](https://github.com/tailwindlabs/tailwindcss/pull/7924), [#8526](https://github.com/tailwindlabs/tailwindcss/pull/8526))
|
|
54
|
+
- Add `grid-flow-dense` utility ([#8193](https://github.com/tailwindlabs/tailwindcss/pull/8193))
|
|
55
|
+
- Add `mix-blend-plus-lighter` utility ([#8288](https://github.com/tailwindlabs/tailwindcss/pull/8288))
|
|
56
|
+
- Add arbitrary variants ([#8299](https://github.com/tailwindlabs/tailwindcss/pull/8299))
|
|
57
|
+
- Add experimental `matchVariant` API ([#8310](https://github.com/tailwindlabs/tailwindcss/pull/8310), [34fd0fb8](https://github.com/tailwindlabs/tailwindcss/commit/34fd0fb82aa574cddc5c7aa3ad7d1af5e3735e5d))
|
|
58
|
+
- Add `prefers-contrast` media query variants ([#8410](https://github.com/tailwindlabs/tailwindcss/pull/8410))
|
|
59
|
+
- Add opacity support when referencing colors with `theme` function ([#8416](https://github.com/tailwindlabs/tailwindcss/pull/8416))
|
|
60
|
+
- Add `postcss-import` support to the CLI ([#8437](https://github.com/tailwindlabs/tailwindcss/pull/8437))
|
|
61
|
+
- Add `optional` variant ([#8486](https://github.com/tailwindlabs/tailwindcss/pull/8486))
|
|
62
|
+
- Add `<alpha-value>` placeholder support for custom colors ([#8501](https://github.com/tailwindlabs/tailwindcss/pull/8501))
|
|
63
|
+
|
|
64
|
+
## [3.0.24] - 2022-04-12
|
|
13
65
|
|
|
14
66
|
### Fixed
|
|
15
67
|
|
|
@@ -27,6 +79,7 @@ Nothing yet!
|
|
|
27
79
|
- Allow for custom properties in `rgb`, `rgba`, `hsl` and `hsla` colors ([#7933](https://github.com/tailwindlabs/tailwindcss/pull/7933))
|
|
28
80
|
- 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
81
|
- Ensure the `percentage` data type is validated correctly ([#8015](https://github.com/tailwindlabs/tailwindcss/pull/8015))
|
|
82
|
+
- Make sure `font-weight` is inherited by form controls in all browsers ([#8078](https://github.com/tailwindlabs/tailwindcss/pull/8078))
|
|
30
83
|
|
|
31
84
|
### Changed
|
|
32
85
|
|
|
@@ -1899,7 +1952,8 @@ No release notes
|
|
|
1899
1952
|
|
|
1900
1953
|
- Everything!
|
|
1901
1954
|
|
|
1902
|
-
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0
|
|
1955
|
+
[unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.0...HEAD
|
|
1956
|
+
[3.1.0]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.24...v3.1.0
|
|
1903
1957
|
[3.0.24]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.23...v3.0.24
|
|
1904
1958
|
[3.0.23]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.22...v3.0.23
|
|
1905
1959
|
[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,8 @@ 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
|
|
419
429
|
];
|
|
420
430
|
}
|
|
421
431
|
function resolveConfig() {
|
|
@@ -437,9 +447,12 @@ async function build() {
|
|
|
437
447
|
}
|
|
438
448
|
});
|
|
439
449
|
resolvedConfig.content.files = files;
|
|
450
|
+
resolvedConfig = (0, _validateConfigJs).validateConfig(resolvedConfig);
|
|
440
451
|
return resolvedConfig;
|
|
441
452
|
}
|
|
442
|
-
|
|
453
|
+
let resolvedConfig = (0, _resolveConfig).default(config);
|
|
454
|
+
resolvedConfig = (0, _validateConfigJs).validateConfig(resolvedConfig);
|
|
455
|
+
return resolvedConfig;
|
|
443
456
|
}
|
|
444
457
|
function extractFileGlobs(config) {
|
|
445
458
|
return config.content.files.filter((file)=>{
|
|
@@ -447,8 +460,7 @@ async function build() {
|
|
|
447
460
|
// like an object it's probably a raw content object. But this object
|
|
448
461
|
// is not watchable, so let's remove it.
|
|
449
462
|
return typeof file === "string";
|
|
450
|
-
}).map((glob)=>(0, _normalizePath).default(glob)
|
|
451
|
-
);
|
|
463
|
+
}).map((glob)=>(0, _normalizePath).default(glob));
|
|
452
464
|
}
|
|
453
465
|
function extractRawContent(config) {
|
|
454
466
|
return config.content.files.filter((file)=>{
|
|
@@ -491,9 +503,39 @@ async function build() {
|
|
|
491
503
|
};
|
|
492
504
|
};
|
|
493
505
|
tailwindPlugin.postcss = true;
|
|
494
|
-
let
|
|
506
|
+
let IMPORT_COMMENT = "__TAILWIND_RESTORE_IMPORT__: ";
|
|
507
|
+
let [beforePlugins, afterPlugins, postcssOptions] = includePostCss ? await loadPostCssPlugins() : [
|
|
508
|
+
[
|
|
509
|
+
(root)=>{
|
|
510
|
+
root.walkAtRules("import", (rule)=>{
|
|
511
|
+
if (rule.params.slice(1).startsWith("tailwindcss/")) {
|
|
512
|
+
rule.after(postcss.comment({
|
|
513
|
+
text: IMPORT_COMMENT + rule.params
|
|
514
|
+
}));
|
|
515
|
+
rule.remove();
|
|
516
|
+
}
|
|
517
|
+
});
|
|
518
|
+
},
|
|
519
|
+
(()=>{
|
|
520
|
+
try {
|
|
521
|
+
return require("postcss-import");
|
|
522
|
+
} catch {}
|
|
523
|
+
return (0, _indexJs).lazyPostcssImport();
|
|
524
|
+
})(),
|
|
525
|
+
(root)=>{
|
|
526
|
+
root.walkComments((rule)=>{
|
|
527
|
+
if (rule.text.startsWith(IMPORT_COMMENT)) {
|
|
528
|
+
rule.after(postcss.atRule({
|
|
529
|
+
name: "import",
|
|
530
|
+
params: rule.text.replace(IMPORT_COMMENT, "")
|
|
531
|
+
}));
|
|
532
|
+
rule.remove();
|
|
533
|
+
}
|
|
534
|
+
});
|
|
535
|
+
},
|
|
536
|
+
],
|
|
495
537
|
[],
|
|
496
|
-
|
|
538
|
+
{},
|
|
497
539
|
];
|
|
498
540
|
let plugins = [
|
|
499
541
|
...beforePlugins,
|
|
@@ -523,17 +565,17 @@ async function build() {
|
|
|
523
565
|
return (0, _indexJs).lazyCssnano()(options);
|
|
524
566
|
})(),
|
|
525
567
|
].filter(Boolean);
|
|
526
|
-
let
|
|
568
|
+
let postcss = loadPostcss();
|
|
569
|
+
let processor = postcss(plugins);
|
|
527
570
|
function processCSS(css) {
|
|
528
571
|
let start = process.hrtime.bigint();
|
|
529
572
|
return Promise.resolve().then(()=>output ? _fs.default.promises.mkdir(_path.default.dirname(output), {
|
|
530
573
|
recursive: true
|
|
531
|
-
}) : null
|
|
532
|
-
|
|
574
|
+
}) : null).then(()=>processor.process(css, {
|
|
575
|
+
...postcssOptions,
|
|
533
576
|
from: input,
|
|
534
577
|
to: output
|
|
535
|
-
})
|
|
536
|
-
).then((result)=>{
|
|
578
|
+
})).then((result)=>{
|
|
537
579
|
if (!output) {
|
|
538
580
|
return process.stdout.write(result.css);
|
|
539
581
|
}
|
|
@@ -544,7 +586,7 @@ async function build() {
|
|
|
544
586
|
}).then(()=>{
|
|
545
587
|
let end = process.hrtime.bigint();
|
|
546
588
|
console.error();
|
|
547
|
-
console.error("Done in", (end - start) / BigInt(
|
|
589
|
+
console.error("Done in", (end - start) / BigInt(1e6) + "ms.");
|
|
548
590
|
});
|
|
549
591
|
}
|
|
550
592
|
let css1 = await (()=>{
|
|
@@ -573,8 +615,7 @@ async function build() {
|
|
|
573
615
|
delete require.cache[require.resolve(file1)];
|
|
574
616
|
}
|
|
575
617
|
if (configPath) {
|
|
576
|
-
configDependencies = (0, _getModuleDependencies).default(configPath).map(({ file })=>file
|
|
577
|
-
);
|
|
618
|
+
configDependencies = (0, _getModuleDependencies).default(configPath).map(({ file })=>file);
|
|
578
619
|
for (let dependency of configDependencies){
|
|
579
620
|
contextDependencies.add(dependency);
|
|
580
621
|
}
|
|
@@ -643,17 +684,16 @@ async function build() {
|
|
|
643
684
|
let tailwindPluginIdx = plugins.indexOf("__TAILWIND_PLUGIN_POSITION__");
|
|
644
685
|
let copy = plugins.slice();
|
|
645
686
|
copy.splice(tailwindPluginIdx, 1, tailwindPlugin);
|
|
646
|
-
let
|
|
687
|
+
let postcss = loadPostcss();
|
|
688
|
+
let processor = postcss(copy);
|
|
647
689
|
function processCSS(css) {
|
|
648
690
|
let start = process.hrtime.bigint();
|
|
649
691
|
return Promise.resolve().then(()=>output ? _fs.default.promises.mkdir(_path.default.dirname(output), {
|
|
650
692
|
recursive: true
|
|
651
|
-
}) : null
|
|
652
|
-
).then(()=>processor.process(css, {
|
|
693
|
+
}) : null).then(()=>processor.process(css, {
|
|
653
694
|
from: input,
|
|
654
695
|
to: output
|
|
655
|
-
})
|
|
656
|
-
).then(async (result)=>{
|
|
696
|
+
})).then(async (result)=>{
|
|
657
697
|
for (let message of result.messages){
|
|
658
698
|
if (message.type === "dependency") {
|
|
659
699
|
contextDependencies.add(message.file);
|
|
@@ -671,7 +711,7 @@ async function build() {
|
|
|
671
711
|
].filter(Boolean));
|
|
672
712
|
}).then(()=>{
|
|
673
713
|
let end = process.hrtime.bigint();
|
|
674
|
-
console.error("Done in", (end - start) / BigInt(
|
|
714
|
+
console.error("Done in", (end - start) / BigInt(1e6) + "ms.");
|
|
675
715
|
}).catch((err)=>{
|
|
676
716
|
if (err.name === "CssSyntaxError") {
|
|
677
717
|
console.error(err.toString());
|
|
@@ -696,13 +736,13 @@ async function build() {
|
|
|
696
736
|
env.DEBUG && console.timeEnd("Finished in");
|
|
697
737
|
return result1;
|
|
698
738
|
}
|
|
699
|
-
let
|
|
739
|
+
let config2 = refreshConfig(configPath);
|
|
700
740
|
if (input) {
|
|
701
741
|
contextDependencies.add(_path.default.resolve(input));
|
|
702
742
|
}
|
|
703
743
|
watcher = _chokidar.default.watch([
|
|
704
744
|
...contextDependencies,
|
|
705
|
-
...extractFileGlobs(
|
|
745
|
+
...extractFileGlobs(config2)
|
|
706
746
|
], {
|
|
707
747
|
usePolling: shouldPoll,
|
|
708
748
|
interval: shouldPoll ? pollInterval : undefined,
|
|
@@ -717,16 +757,16 @@ async function build() {
|
|
|
717
757
|
if (contextDependencies.has(file)) {
|
|
718
758
|
env.DEBUG && console.time("Resolve config");
|
|
719
759
|
context = null;
|
|
720
|
-
|
|
760
|
+
config2 = refreshConfig(configPath);
|
|
721
761
|
env.DEBUG && console.timeEnd("Resolve config");
|
|
722
762
|
env.DEBUG && console.time("Watch new files");
|
|
723
|
-
let globs = extractFileGlobs(
|
|
763
|
+
let globs = extractFileGlobs(config2);
|
|
724
764
|
watcher.add(configDependencies);
|
|
725
765
|
watcher.add(globs);
|
|
726
766
|
env.DEBUG && console.timeEnd("Watch new files");
|
|
727
767
|
chain = chain.then(async ()=>{
|
|
728
|
-
changedContent.push(...getChangedContent(
|
|
729
|
-
await rebuild(
|
|
768
|
+
changedContent.push(...getChangedContent(config2));
|
|
769
|
+
await rebuild(config2);
|
|
730
770
|
});
|
|
731
771
|
} else {
|
|
732
772
|
chain = chain.then(async ()=>{
|
|
@@ -734,7 +774,7 @@ async function build() {
|
|
|
734
774
|
content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
|
|
735
775
|
extension: _path.default.extname(file).slice(1)
|
|
736
776
|
});
|
|
737
|
-
await rebuild(
|
|
777
|
+
await rebuild(config2);
|
|
738
778
|
});
|
|
739
779
|
}
|
|
740
780
|
});
|
|
@@ -744,18 +784,19 @@ async function build() {
|
|
|
744
784
|
content: _fs.default.readFileSync(_path.default.resolve(file), "utf8"),
|
|
745
785
|
extension: _path.default.extname(file).slice(1)
|
|
746
786
|
});
|
|
747
|
-
await rebuild(
|
|
787
|
+
await rebuild(config2);
|
|
748
788
|
});
|
|
749
789
|
});
|
|
750
790
|
chain = chain.then(()=>{
|
|
751
|
-
changedContent.push(...getChangedContent(
|
|
752
|
-
return rebuild(
|
|
791
|
+
changedContent.push(...getChangedContent(config2));
|
|
792
|
+
return rebuild(config2);
|
|
753
793
|
});
|
|
754
794
|
}
|
|
755
795
|
if (shouldWatch) {
|
|
756
|
-
/* Abort the watcher if stdin is closed to avoid zombie processes */ process.stdin.
|
|
757
|
-
|
|
758
|
-
|
|
796
|
+
/* Abort the watcher if stdin is closed to avoid zombie processes */ if (process.stdin.isTTY) {
|
|
797
|
+
process.stdin.on("end", ()=>process.exit(0));
|
|
798
|
+
process.stdin.resume();
|
|
799
|
+
}
|
|
759
800
|
startWatcher();
|
|
760
801
|
} else {
|
|
761
802
|
buildOnce();
|