-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Add @source not support
#17255
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add @source not support
#17255
Conversation
41102c9 to
39588cf
Compare
d3700cc to
41e1ac2
Compare
d1d31ef to
97f9505
Compare
This reverts commit fb4d8d8.
3d2fc5c to
5e9cdf8
Compare
5e9cdf8 to
9d4c2af
Compare
We didn't add a changelog for the PR (#17255) and there are a few things we need to talk about. So opened this PR to get everything in and once we're happy we can merge it in one go instead of changing on `main` directly. --------- Co-authored-by: Philipp Spiess <hello@philippspiess.com>
We didn't add a changelog for the PR (#17255) and there are a few things we need to talk about. So opened this PR to get everything in and once we're happy we can merge it in one go instead of changing on `main` directly. --------- Co-authored-by: Philipp Spiess <hello@philippspiess.com>
|
@RobinMalfait Curious, is there a way to inspect the generated ignore list and emit what file change lead to another rebuild? Even with that new Our setup is more complex as we use 3 separate builds for the marketing site, the admin UI and the booking engine. It’s roughly the following structure: The import base from "../../../../tailwind.config.js"
/** @type {import('tailwindcss').Config} */
export default {
presets: [base],
content: [
"./app/views/cms/**/*.erb",
"./app/views/common/**/*.erb",
"./app/views/layouts/cms*.erb",
"./app/helpers/cms*.rb",
"./app/helpers/cms/**/*.rb",
"./app/assets/stylesheets/cms/application.tailwind.css",
"./app/javascript/controllers/pages/**/*.{js,ts}",
],
};with the /** @type {import('tailwindcss').Config} */
export default {
theme: {
…
},
prefix: "tw"
};We’re migrating from v3 hence why there are so many |
As of v4.1.0, Tailwind ignores the `node_modules` directory by default, regardless of your `.gitignore` settings. * https://github.com/tailwindlabs/tailwindcss/blob/main/CHANGELOG.md#410---2025-04-01 > Ignore `node_modules` by default (can be overridden by `@source` … rules) (tailwindlabs/tailwindcss#17255) This is worth mentioning in the relevant sections of the documentation: * [Which files are scanned](https://tailwindcss-com-git-fork-rozsazoltan-update-604522-tailwindlabs.vercel.app/docs/detecting-classes-in-source-files#which-files-are-scanned) - Preview
|
@ur5us did you figure anything out on this? Using |
|
@jclusso No, I have not. Due to time constraints I've had to stay on v3 and work on actual features. Might revisit in 1 – 2 months. |
This PR adds a new source detection feature:
@source not "…". It can be used to exclude files specifically from your source configuration without having to think about creating a rule that matches all but the requested file:While working on this feature, we noticed that there are multiple places with different heuristics we used to scan the file system. These are:
@source "./my-dir")@source "./**/*.bin"— these contain file extensions)Because of the different heuristics, we were able to construct failing cases (e.g. when you create a new file into
my-dirthat would be thrown out by auto-source detection, it'd would actually be scanned). We were also leaving a lot of performance on the table as the file system is traversed multiple times for certain problems.To resolve these issues, we're now unifying all of these systems into one
ignorecrate walker setup. We also implemented features like auto-source-detection and thenotflag as additional gitignore rules only, avoid the need for a lot of custom code needed to make decisions.High level, this is what happens after the now:
@sourcerules into a list of roots (that is the source directory for this rule) and optional globs (that is the actual rules for files in this file). For custom sources (i.e with a customglob), we add an allowlist rule to the gitignore setup, so that we can be sure these files are always included.@sourcerule, we create respective ignore rules.So, consider the following setup:
This creates a git ignore file that (simplified) looks like this:
We then use this information on top of your existing
.gitignoresetup to resolve files (i.e so if your.gitignorecontains rules e.g.dist/this line is going to be added before any of the rules lined out in the example above. This allows negative rules to allow-list your.gitignorerules.To implement this, we're rely on the
ignorecrate but we had to make various changes, very specific, to it so we decided to fork the crate. All changes are prefixed with a// CHANGED:block but here are the most-important ones:.gitignorerulesBehavioral changes
@sourcenow wins over your.gitignorefile and the auto-content rules.node_modulesand.gitfolders as well as the.gitignorefile are now ignored by default (but can be overridden by an explicit@sourcerule).node_modules) now also win over your.gitignoreconfiguration and auto-content rules.@source not "…"to negate any previous rules.contentrules in your legacy JavaScript configuration (e.g.content: ['!./src']) now work with v4.@sourcedefinitions matter now, because you can technically include or negate previous rules. This is similar to your.gitingorefile.@sourceconfiguration into accountCombining with other features
Note that the
notflag is also already compatible with@source inline(…)added in an earlier commit:Test plan
@source not "…"specific examples and updated the existing tests to match the subtle behavior changes[ci-all]that, when added to the description of a PR, causes the PR to run unit and integration tests on all operating systems.[ci-all]