Skip to content
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

Eleventy (npm/x?) should follow git's rule expressions. #857

Open
dsthedev opened this issue Jan 14, 2020 · 5 comments
Open

Eleventy (npm/x?) should follow git's rule expressions. #857

dsthedev opened this issue Jan 14, 2020 · 5 comments
Labels
feature: 🪞 ignores Ignores, via configuration API or .eleventyignore or .gitignore etc needs-triage

Comments

@dsthedev
Copy link

If an asterisk is used to expand a .gitignore's folder rule, Eleventy will not follow that rule and attempts to scan the entire node_modules/ folder.

Steps to Reproduce

  1. Add this to a project's .gitignore file (or simply add the * to an existing folder's rule):
# Node
node_modules*/

# or
src*/
  1. Run npx eleventy

Expected behavior

Just like git, Eleventy should expand the rule to include both the node modules folder, and any folder that starts with node_modules (i.e: node_modules-OLD).

Actual Behavior

Ignore rule is ignored, and 11ty proceeds to scan the "ignored" folders.

Environment:

  • macOS Catalina 10.15.2
  • Eleventy Version 0.10.0

Fresh install with only a few basic templates. No .eleventyignore file either.

FWIW

Warning, personal opinion incoming; feel free to ignore!

I just checked the docs for 11ty's ignore rules, and I find it odd that it even attempts to use the .gitignore file at all. I only looked because I was scratching my head for a good 20m wondering why my perfectly running basic 11ty install magically stopped working. I've never seen another tool use gits config files like this before, and in my opinion it shouldn't. That ignore file is for git and git alone.

Regardless, if using gitignore is a default option, it should follow the same expression rules!

@samuelpath
Copy link
Contributor

@dsthedev I don't know if you saw and if it's relevant but you can opt out of using .gitignore:
https://www.11ty.dev/docs/ignores/#opt-out-of-using-.gitignore

@zachleat in the documentation, you say:

Paths listed in your project’s .gitignore file are automatically ignored.

Can you provide the rationale for that? Why use the .gitignore folder at all in Eleventy? Isn't this like mixing 2 things which should not be related (the version control and the actual use of the solution)?

@benlaverriere
Copy link

As another anecdote, I ran into some trouble deploying an Eleventy site with Netlify because a nested node_modules directory wasn't ignored. (A huge thank you for the debug output; I hadn't used it before now and it was super helpful!)

The .gitignore docs suggest that foo and **/foo will both ignore the same directory, but since Eleventy calls TemplatePath.addLeadingDotSlash for every ignore-entry, these become ./foo and ./**/foo and match different things. (In my case, changing my .gitignore from node_modules to **/node_modules successfully excluded ./.netlify/plugins/node_modules from the Eleventy build.)

I'll probably also switch to an .eleventyignore file just for my own memory's sake 😅 but I wonder if this behavior should be documented/guarded somehow. I don't see a clear way to catch these on the fly the way negative ignore rules are, but maybe a doc update would help? I'm happy to draft a docs PR if that appeals.

@zachleat zachleat added the feature: 🪞 ignores Ignores, via configuration API or .eleventyignore or .gitignore etc label Jun 29, 2022
@zachleat
Copy link
Member

I don’t have much time to respond to this as comprehensively as I’d like right now but I will say that the choice to use .gitignore here has been both a positive and a negative.

It was confusing for beginners using "." as their input directory before we defaulted to ignore node_modules by default #383 (and now .git in the next 2.0 canary #2394).

@zachleat
Copy link
Member

Also related #2436

@Bludator
Copy link

Please, please document the catches with the .gitignore, I just fall into the trap with negative patterns.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature: 🪞 ignores Ignores, via configuration API or .eleventyignore or .gitignore etc needs-triage
Projects
None yet
Development

No branches or pull requests

5 participants