Commit d68a780
Auto source detection improvements (#14820)
This PR introduces a new `source(…)` argument and improves on the
existing `@source`. The goal of this PR is to make the automatic source
detection configurable, let's dig in.
By default, we will perform automatic source detection starting at the
current working directory. Auto source detection will find plain text
files (no binaries, images, ...) and will ignore git-ignored files.
If you want to start from a different directory, you can use the new
`source(…)` next to the `@import "tailwindcss/utilities"
layer(utilities) source(…)`.
E.g.:
```css
/* ./src/styles/index.css */
@import 'tailwindcss/utilities' layer(utilities) source('../../');
```
Most people won't split their source files, and will just use the simple
`@import "tailwindcss";`, because of this reason, you can use
`source(…)` on the import as well:
E.g.:
```css
/* ./src/styles/index.css */
@import 'tailwindcss' source('../../');
```
Sometimes, you want to rely on auto source detection, but also want to
look in another directory for source files. In this case, yuo can use
the `@source` directive:
```css
/* ./src/index.css */
@import 'tailwindcss';
/* Look for `blade.php` files in `../resources/views` */
@source '../resources/views/**/*.blade.php';
```
However, you don't need to specify the extension, instead you can just
point the directory and all the same automatic source detection rules
will apply.
```css
/* ./src/index.css */
@import 'tailwindcss';
@source '../resources/views';
```
If, for whatever reason, you want to disable the default source
detection feature entirely, and only want to rely on very specific glob
patterns you define, then you can disable it via `source(none)`.
```css
/* Completely disable the default auto source detection */
@import 'tailwindcss' source(none);
/* Only look at .blade.php files, nothing else */
@source "../resources/views/**/*.blade.php";
```
Note: even with `source(none)`, if your `@source` points to a directory,
then auto source detection will still be performed in that directory. If
you don't want that, then you can simply add explicit files in the globs
as seen in the previous example.
```css
/* Completely disable the default auto source detection */
@import 'tailwindcss' source(none);
/* Run auto source detection in `../resources/views` */
@source "../resources/views";
```
---------
Co-authored-by: Jordan Pittman <jordan@cryptica.me>
Co-authored-by: Adam Wathan <4323180+adamwathan@users.noreply.github.com>1 parent c439cdf commit d68a780
File tree
24 files changed
+2339
-604
lines changed- crates
- node/src
- oxide
- src
- scanner
- tests
- integrations
- cli
- postcss
- vite
- packages
- @tailwindcss-cli/src/commands/build
- @tailwindcss-node/src
- @tailwindcss-postcss/src
- @tailwindcss-upgrade/src
- @tailwindcss-vite/src
- tailwindcss/src
24 files changed
+2339
-604
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
13 | 16 | | |
14 | 17 | | |
| |||
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
| 24 | + | |
21 | 25 | | |
22 | 26 | | |
23 | 27 | | |
| |||
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
22 | | - | |
23 | | - | |
24 | | - | |
25 | | - | |
26 | | - | |
27 | | - | |
28 | 21 | | |
29 | 22 | | |
30 | 23 | | |
| |||
62 | 55 | | |
63 | 56 | | |
64 | 57 | | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | 58 | | |
72 | 59 | | |
73 | 60 | | |
74 | 61 | | |
75 | 62 | | |
76 | | - | |
77 | | - | |
78 | | - | |
79 | 63 | | |
80 | 64 | | |
81 | 65 | | |
| |||
102 | 86 | | |
103 | 87 | | |
104 | 88 | | |
105 | | - | |
106 | 89 | | |
107 | 90 | | |
108 | 91 | | |
| |||
128 | 111 | | |
129 | 112 | | |
130 | 113 | | |
131 | | - | |
| 114 | + | |
132 | 115 | | |
133 | 116 | | |
134 | 117 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
31 | 31 | | |
32 | 32 | | |
33 | 33 | | |
34 | | - | |
35 | | - | |
36 | | - | |
| 34 | + | |
37 | 35 | | |
38 | 36 | | |
39 | 37 | | |
40 | | - | |
| 38 | + | |
41 | 39 | | |
42 | 40 | | |
43 | 41 | | |
44 | 42 | | |
45 | 43 | | |
46 | 44 | | |
47 | | - | |
| 45 | + | |
48 | 46 | | |
49 | 47 | | |
50 | 48 | | |
| |||
66 | 64 | | |
67 | 65 | | |
68 | 66 | | |
69 | | - | |
70 | 67 | | |
71 | 68 | | |
72 | 69 | | |
73 | 70 | | |
74 | 71 | | |
75 | | - | |
76 | 72 | | |
77 | 73 | | |
78 | 74 | | |
79 | 75 | | |
80 | 76 | | |
81 | | - | |
82 | 77 | | |
83 | 78 | | |
84 | 79 | | |
| |||
87 | 82 | | |
88 | 83 | | |
89 | 84 | | |
90 | | - | |
91 | 85 | | |
92 | 86 | | |
93 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
| 18 | + | |
| 19 | + | |
19 | 20 | | |
20 | 21 | | |
21 | 22 | | |
0 commit comments