tailwindcss 0.0.0-insiders.89bf2ed → 0.0.0-insiders.8b152e7

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.
Files changed (85) hide show
  1. package/CHANGELOG.md +102 -4
  2. package/defaultTheme.d.ts +2 -1
  3. package/lib/cli-peer-dependencies.js +8 -3
  4. package/lib/cli.js +116 -72
  5. package/lib/corePlugins.js +120 -86
  6. package/lib/css/preflight.css +0 -8
  7. package/lib/featureFlags.js +8 -6
  8. package/lib/index.js +1 -2
  9. package/lib/lib/cacheInvalidation.js +32 -14
  10. package/lib/lib/collapseAdjacentRules.js +1 -2
  11. package/lib/lib/defaultExtractor.js +216 -32
  12. package/lib/lib/evaluateTailwindFunctions.js +58 -14
  13. package/lib/lib/expandApplyAtRules.js +47 -23
  14. package/lib/lib/expandTailwindAtRules.js +40 -26
  15. package/lib/lib/generateRules.js +125 -50
  16. package/lib/lib/regex.js +52 -0
  17. package/lib/lib/resolveDefaultsAtRules.js +56 -45
  18. package/lib/lib/setupContextUtils.js +138 -79
  19. package/lib/lib/setupTrackingContext.js +7 -9
  20. package/lib/lib/sharedState.js +1 -2
  21. package/lib/lib/substituteScreenAtRules.js +1 -2
  22. package/lib/postcss-plugins/nesting/plugin.js +1 -2
  23. package/lib/util/buildMediaQuery.js +1 -2
  24. package/lib/util/cloneDeep.js +2 -4
  25. package/lib/util/color.js +26 -36
  26. package/lib/util/createPlugin.js +1 -2
  27. package/lib/util/createUtilityPlugin.js +1 -2
  28. package/lib/util/dataTypes.js +11 -16
  29. package/lib/util/flattenColorPalette.js +2 -5
  30. package/lib/util/formatVariantSelector.js +65 -57
  31. package/lib/util/getAllConfigs.js +10 -5
  32. package/lib/util/isValidArbitraryValue.js +1 -2
  33. package/lib/util/log.js +2 -3
  34. package/lib/util/negateValue.js +1 -2
  35. package/lib/util/normalizeConfig.js +33 -23
  36. package/lib/util/normalizeScreens.js +1 -2
  37. package/lib/util/parseAnimationValue.js +1 -2
  38. package/lib/util/parseBoxShadowValue.js +2 -43
  39. package/lib/util/pluginUtils.js +11 -3
  40. package/lib/util/removeAlphaVariables.js +18 -0
  41. package/lib/util/resolveConfig.js +57 -56
  42. package/lib/util/splitAtTopLevelOnly.js +90 -0
  43. package/lib/util/transformThemeValue.js +4 -2
  44. package/lib/util/validateConfig.js +21 -0
  45. package/lib/util/withAlphaVariable.js +5 -5
  46. package/package.json +19 -17
  47. package/peers/index.js +3598 -1501
  48. package/plugin.d.ts +10 -5
  49. package/scripts/generate-types.js +53 -0
  50. package/scripts/type-utils.js +27 -0
  51. package/src/cli-peer-dependencies.js +7 -1
  52. package/src/cli.js +104 -27
  53. package/src/corePlugins.js +77 -42
  54. package/src/css/preflight.css +0 -8
  55. package/src/featureFlags.js +2 -2
  56. package/src/lib/defaultExtractor.js +193 -35
  57. package/src/lib/evaluateTailwindFunctions.js +56 -6
  58. package/src/lib/expandApplyAtRules.js +59 -6
  59. package/src/lib/expandTailwindAtRules.js +4 -4
  60. package/src/lib/generateRules.js +87 -14
  61. package/src/lib/regex.js +74 -0
  62. package/src/lib/resolveDefaultsAtRules.js +53 -36
  63. package/src/lib/setupContextUtils.js +117 -39
  64. package/src/lib/setupTrackingContext.js +4 -0
  65. package/src/util/color.js +20 -18
  66. package/src/util/dataTypes.js +4 -6
  67. package/src/util/formatVariantSelector.js +82 -63
  68. package/src/util/getAllConfigs.js +7 -0
  69. package/src/util/log.js +1 -1
  70. package/src/util/normalizeConfig.js +0 -8
  71. package/src/util/parseBoxShadowValue.js +3 -50
  72. package/src/util/pluginUtils.js +13 -1
  73. package/src/util/removeAlphaVariables.js +24 -0
  74. package/src/util/resolveConfig.js +66 -52
  75. package/src/util/splitAtTopLevelOnly.js +71 -0
  76. package/src/util/toPath.js +1 -1
  77. package/src/util/transformThemeValue.js +4 -2
  78. package/src/util/validateConfig.js +13 -0
  79. package/src/util/withAlphaVariable.js +1 -1
  80. package/stubs/defaultConfig.stub.js +2 -1
  81. package/stubs/simpleConfig.stub.js +1 -0
  82. package/types/config.d.ts +33 -29
  83. package/types/generated/default-theme.d.ts +331 -0
  84. package/types/index.d.ts +7 -1
  85. package/types.d.ts +0 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,69 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ - Nothing yet!
11
+
12
+ ## [3.1.6] - 2022-07-11
13
+
14
+ ### Fixed
15
+
16
+ - Fix usage on Node 12.x ([b4e637e](https://github.com/tailwindlabs/tailwindcss/commit/b4e637e2e096a9d6f2210efba9541f6fd4f28e56))
17
+ - Handle theme keys with slashes when using `theme()` in CSS ([#8831](https://github.com/tailwindlabs/tailwindcss/pull/8831))
18
+
19
+ ## [3.1.5] - 2022-07-07
20
+
21
+ ### Added
22
+
23
+ - Support configuring a default `font-weight` for each font size utility ([#8763](https://github.com/tailwindlabs/tailwindcss/pull/8763))
24
+ - Add support for alpha values in safe list ([#8774](https://github.com/tailwindlabs/tailwindcss/pull/8774))
25
+
26
+ ### Fixed
27
+
28
+ - Improve types to support fallback values in the CSS-in-JS syntax used in plugin APIs ([#8762](https://github.com/tailwindlabs/tailwindcss/pull/8762))
29
+ - Support including `tailwindcss` and `autoprefixer` in `postcss.config.js` in standalone CLI ([#8769](https://github.com/tailwindlabs/tailwindcss/pull/8769))
30
+ - Fix using special-characters as prefixes ([#8772](https://github.com/tailwindlabs/tailwindcss/pull/8772))
31
+ - Don’t prefix classes used within arbitrary variants ([#8773](https://github.com/tailwindlabs/tailwindcss/pull/8773))
32
+ - Add more explicit types for the default theme ([#8780](https://github.com/tailwindlabs/tailwindcss/pull/8780))
33
+
34
+ ## [3.1.4] - 2022-06-21
35
+
36
+ ### Fixed
37
+
38
+ - Provide default to `<alpha-value>` when using `theme()` ([#8652](https://github.com/tailwindlabs/tailwindcss/pull/8652))
39
+ - Detect arbitrary variants with quotes ([#8687](https://github.com/tailwindlabs/tailwindcss/pull/8687))
40
+ - Don’t add spaces around raw `/` that are preceded by numbers ([#8688](https://github.com/tailwindlabs/tailwindcss/pull/8688))
41
+
42
+ ## [3.1.3] - 2022-06-14
43
+
44
+ ### Fixed
45
+
46
+ - Fix extraction of multi-word utilities with arbitrary values and quotes ([#8604](https://github.com/tailwindlabs/tailwindcss/pull/8604))
47
+ - Fix casing of import of `corePluginList` type definition ([#8587](https://github.com/tailwindlabs/tailwindcss/pull/8587))
48
+ - Ignore PostCSS nodes returned by `addVariant` ([#8608](https://github.com/tailwindlabs/tailwindcss/pull/8608))
49
+ - Fix missing spaces around arithmetic operators ([#8615](https://github.com/tailwindlabs/tailwindcss/pull/8615))
50
+ - Detect alpha value in CSS `theme()` function when using quotes ([#8625](https://github.com/tailwindlabs/tailwindcss/pull/8625))
51
+ - Fix "Maximum call stack size exceeded" bug ([#8636](https://github.com/tailwindlabs/tailwindcss/pull/8636))
52
+ - Allow functions returning parallel variants to mutate the container ([#8622](https://github.com/tailwindlabs/tailwindcss/pull/8622))
53
+ - Remove text opacity CSS variables from `::marker` ([#8622](https://github.com/tailwindlabs/tailwindcss/pull/8622))
54
+
55
+ ## [3.1.2] - 2022-06-10
56
+
57
+ ### Fixed
58
+
59
+ - Ensure `\` is a valid arbitrary variant token ([#8576](https://github.com/tailwindlabs/tailwindcss/pull/8576))
60
+ - 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))
61
+
62
+ ## [3.1.1] - 2022-06-09
63
+
64
+ ### Fixed
65
+
66
+ - Fix candidate extractor regression ([#8558](https://github.com/tailwindlabs/tailwindcss/pull/8558))
67
+ - Split `::backdrop` into separate defaults group ([#8567](https://github.com/tailwindlabs/tailwindcss/pull/8567))
68
+ - Fix postcss plugin type ([#8564](https://github.com/tailwindlabs/tailwindcss/pull/8564))
69
+ - Fix class detection in markdown code fences and slim templates ([#8569](https://github.com/tailwindlabs/tailwindcss/pull/8569))
70
+
71
+ ## [3.1.0] - 2022-06-08
72
+
10
73
  ### Fixed
11
74
 
12
75
  - Types: allow for arbitrary theme values (for 3rd party plugins) ([#7926](https://github.com/tailwindlabs/tailwindcss/pull/7926))
@@ -15,11 +78,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
15
78
  - Handle duplicate At Rules without children ([#8122](https://github.com/tailwindlabs/tailwindcss/pull/8122))
16
79
  - Allow arbitrary values with commas in `@apply` ([#8125](https://github.com/tailwindlabs/tailwindcss/pull/8125))
17
80
  - Fix intellisense for plugins with multiple `@apply` rules ([#8213](https://github.com/tailwindlabs/tailwindcss/pull/8213))
81
+ - Improve type detection for arbitrary color values ([#8201](https://github.com/tailwindlabs/tailwindcss/pull/8201))
82
+ - Support PostCSS config options in config file in CLI ([#8226](https://github.com/tailwindlabs/tailwindcss/pull/8226))
83
+ - Remove default `[hidden]` style in preflight ([#8248](https://github.com/tailwindlabs/tailwindcss/pull/8248))
84
+ - Only check selectors containing base apply candidates for circular dependencies ([#8222](https://github.com/tailwindlabs/tailwindcss/pull/8222))
85
+ - Rewrite default class extractor ([#8204](https://github.com/tailwindlabs/tailwindcss/pull/8204))
86
+ - Move `important` selector to the front when `@apply`-ing selector-modifying variants in custom utilities ([#8313](https://github.com/tailwindlabs/tailwindcss/pull/8313))
87
+ - Error when registering an invalid custom variant ([#8345](https://github.com/tailwindlabs/tailwindcss/pull/8345))
88
+ - Create tailwind.config.cjs file in ESM package when running init ([#8363](https://github.com/tailwindlabs/tailwindcss/pull/8363))
89
+ - Fix `matchVariants` that use at-rules and placeholders ([#8392](https://github.com/tailwindlabs/tailwindcss/pull/8392))
90
+ - Improve types of the `tailwindcss/plugin` ([#8400](https://github.com/tailwindlabs/tailwindcss/pull/8400))
91
+ - Allow returning parallel variants from `addVariant` or `matchVariant` callback functions ([#8455](https://github.com/tailwindlabs/tailwindcss/pull/8455))
92
+ - Try using local `postcss` installation first in the CLI ([#8270](https://github.com/tailwindlabs/tailwindcss/pull/8270))
93
+ - Allow default ring color to be a function ([#7587](https://github.com/tailwindlabs/tailwindcss/pull/7587))
94
+ - Don't inherit `to` value from parent gradients ([#8489](https://github.com/tailwindlabs/tailwindcss/pull/8489))
95
+ - Remove process dependency from log functions ([#8530](https://github.com/tailwindlabs/tailwindcss/pull/8530))
96
+ - Ensure we can use `@import 'tailwindcss/...'` without node_modules ([#8537](https://github.com/tailwindlabs/tailwindcss/pull/8537))
97
+
98
+ ### Changed
99
+
100
+ - Only apply hover styles when supported (future) ([#8394](https://github.com/tailwindlabs/tailwindcss/pull/8394))
101
+ - Respect default ring color opacity (future) ([#8448](https://github.com/tailwindlabs/tailwindcss/pull/8448), [3f4005e](https://github.com/tailwindlabs/tailwindcss/commit/3f4005e833445f7549219eb5ae89728cbb3a2630))
18
102
 
19
103
  ### Added
20
104
 
21
- - Allow default ring color to be a function ([#7587](https://github.com/tailwindlabs/tailwindcss/pull/7587))
22
- - Add `rgb` and `hsl` color helpers for CSS variables ([#7665](https://github.com/tailwindlabs/tailwindcss/pull/7665))
23
105
  - Support PostCSS `Document` nodes ([#7291](https://github.com/tailwindlabs/tailwindcss/pull/7291))
24
106
  - Add `text-start` and `text-end` utilities ([#6656](https://github.com/tailwindlabs/tailwindcss/pull/6656))
25
107
  - Support customizing class name when using `darkMode: 'class'` ([#5800](https://github.com/tailwindlabs/tailwindcss/pull/5800))
@@ -27,7 +109,16 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
27
109
  - Add new `border-spacing` utilities ([#7102](https://github.com/tailwindlabs/tailwindcss/pull/7102))
28
110
  - Add `enabled` variant ([#7905](https://github.com/tailwindlabs/tailwindcss/pull/7905))
29
111
  - Add TypeScript types for the `tailwind.config.js` file ([#7891](https://github.com/tailwindlabs/tailwindcss/pull/7891))
30
- - Add `backdrop` variant ([#7924](https://github.com/tailwindlabs/tailwindcss/pull/7924))
112
+ - Add `backdrop` variant ([#7924](https://github.com/tailwindlabs/tailwindcss/pull/7924), [#8526](https://github.com/tailwindlabs/tailwindcss/pull/8526))
113
+ - Add `grid-flow-dense` utility ([#8193](https://github.com/tailwindlabs/tailwindcss/pull/8193))
114
+ - Add `mix-blend-plus-lighter` utility ([#8288](https://github.com/tailwindlabs/tailwindcss/pull/8288))
115
+ - Add arbitrary variants ([#8299](https://github.com/tailwindlabs/tailwindcss/pull/8299))
116
+ - Add experimental `matchVariant` API ([#8310](https://github.com/tailwindlabs/tailwindcss/pull/8310), [34fd0fb8](https://github.com/tailwindlabs/tailwindcss/commit/34fd0fb82aa574cddc5c7aa3ad7d1af5e3735e5d))
117
+ - Add `prefers-contrast` media query variants ([#8410](https://github.com/tailwindlabs/tailwindcss/pull/8410))
118
+ - Add opacity support when referencing colors with `theme` function ([#8416](https://github.com/tailwindlabs/tailwindcss/pull/8416))
119
+ - Add `postcss-import` support to the CLI ([#8437](https://github.com/tailwindlabs/tailwindcss/pull/8437))
120
+ - Add `optional` variant ([#8486](https://github.com/tailwindlabs/tailwindcss/pull/8486))
121
+ - Add `<alpha-value>` placeholder support for custom colors ([#8501](https://github.com/tailwindlabs/tailwindcss/pull/8501))
31
122
 
32
123
  ## [3.0.24] - 2022-04-12
33
124
 
@@ -1920,7 +2011,14 @@ No release notes
1920
2011
 
1921
2012
  - Everything!
1922
2013
 
1923
- [unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.24...HEAD
2014
+ [unreleased]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.6...HEAD
2015
+ [3.1.6]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.5...v3.1.6
2016
+ [3.1.5]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.4...v3.1.5
2017
+ [3.1.4]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.3...v3.1.4
2018
+ [3.1.3]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.2...v3.1.3
2019
+ [3.1.2]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.1...v3.1.2
2020
+ [3.1.1]: https://github.com/tailwindlabs/tailwindcss/compare/v3.1.0...v3.1.1
2021
+ [3.1.0]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.24...v3.1.0
1924
2022
  [3.0.24]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.23...v3.0.24
1925
2023
  [3.0.23]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.22...v3.0.23
1926
2024
  [3.0.22]: https://github.com/tailwindlabs/tailwindcss/compare/v3.0.21...v3.0.22
package/defaultTheme.d.ts CHANGED
@@ -1,3 +1,4 @@
1
1
  import type { Config } from './types/config'
2
- declare const theme: Config['theme']
2
+ import { DefaultTheme } from './types/generated/default-theme'
3
+ declare const theme: Config['theme'] & DefaultTheme
3
4
  export = theme
@@ -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
- exports.postcss = void 0;
8
- let postcss = require("postcss");
9
- exports.postcss = postcss;
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: "Initialize a full `tailwind.config.js` file"
161
+ description: `Initialize a full \`${configs.tailwind}\` file`
138
162
  },
139
163
  "--postcss": {
140
164
  type: Boolean,
141
- description: "Initialize a `postcss.config.js` file"
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] [--types] [options...]",
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 : "./tailwind.config.js");
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("./postcss.config.js");
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 { plugins: configPlugins } = customPostCssPath ? await (async ()=>{
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
- plugins: (0, _plugins).default(config, file)
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
- return (0, _resolveConfig).default(config);
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 processor = (0, _indexJs).postcss(plugins);
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
- ).then(()=>processor.process(css, {
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(1000000) + "ms.");
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 processor = (0, _indexJs).postcss(copy);
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(1000000) + "ms.");
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 config1 = refreshConfig(configPath);
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(config1)
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
- config1 = refreshConfig(configPath);
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(config1);
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(config1));
727
- await rebuild(config1);
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(config1);
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(config1);
788
+ await rebuild(config2);
746
789
  });
747
790
  });
748
791
  chain = chain.then(()=>{
749
- changedContent.push(...getChangedContent(config1));
750
- return rebuild(config1);
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.on("end", ()=>process.exit(0)
755
- );
756
- process.stdin.resume();
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();