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

Files in addPassthroughCopy with glob not ignored with .eleventyignore #1134

Open
nhoizey opened this issue Apr 29, 2020 · 8 comments
Open
Labels
bug feature: 🪞 ignores Ignores, via configuration API or .eleventyignore or .gitignore etc

Comments

@nhoizey
Copy link
Contributor

nhoizey commented Apr 29, 2020

Describe the bug

I have a call to addPassthroughCopy with a glob to take all images, but one folder is in my .eleventyignore file and the images inside it are copied.

To Reproduce

Reduced test case:

mkdir -p src/ignored
echo "don't copy this" > src/ignored/file.txt
echo "src/ignored" > ./.eleventyignore
echo "module.exports = function (eleventyConfig) { eleventyConfig.addPassthroughCopy('src/**/*.txt'); return { dir: { input: 'src' } }; };" > ./.eleventy.js
npx @11ty/eleventy

Also in one single command:

mkdir -p src/ignored && echo "don't copy this" > src/ignored/file.txt && echo "src/ignored" > ./.eleventyignore && echo "module.exports = function (eleventyConfig) { eleventyConfig.addPassthroughCopy('src/**/*.txt'); return { dir: { input: 'src' } }; };" > ./.eleventy.js && npx @11ty/eleventy

The file src/ignored/file.txt is copied even if src/ignored is in .eleventyignore:

$ tree

.
├── _site
│   └── ignored
│       └── file.txt
└── src
    └── ignored
        └── file.txt

4 directories, 2 files

Expected behavior

I thought (I would like to) addPassthroughCopy respected .eleventyignore.

Environment:

  • macOS 10.15.4
  • Eleventy 0.10.0 as well as master (2020-04-29)
@samuelpath
Copy link
Contributor

Same issue as #1252 ?

@gem0303
Copy link

gem0303 commented Aug 12, 2020

I ran into the same problem and originally posted this as a duplicate issue. I closed that issue and am pasting my comments and notes here.


Describe the bug
When I use a glob in addPassthroughCopy, it appears to be overriding or ignoring my .eleventyignore file.

To Reproduce
I am using the "glob" method with addPassthroughCopy as described in the docs.

module.exports = function(eleventyConfig) {
  eleventyConfig.addPassthroughCopy("**/*.css")
  eleventyConfig.addPassthroughCopy("**/*.js")
}

Site is also set up to copy jpg, png, gif, mp4, and pdf.

My .eleventyignore file looks like this:

_site/
node_modules/

When I run Eleventy, I end up with a node_modules folder inside my output folder (_site). If I run Eleventy again, my _site folder has another _site folder nested inside it. Subsequent runs also throw multiple errors for TemplatePassthroughError, TempateWriterWriteError, TemplatePassthroughManagerCopyError, and Error ENOENT no such file or directory.

The .eleventyignore file does not seem to be working.

Expected behavior
My site should process to the _site folder, and NOT include anything from node_modules. If I run Eleventy again, my _site folder should not have another _site folder nested inside it.

Environment:

  • OS and Version: WIndows 10
  • Eleventy Version 0.11

Additional context
addPassthroughCopy works if I do not use glob syntax, like this:

eleventyConfig.addPassthroughCopy("culture/*/*.gif")
eleventyConfig.addPassthroughCopy("culture/facts.js")

But I have css, js and image files located in several different subfolders. I did not want to have to keep "whitelisting" every file that needed to be passed through. Therefore the glob method made more sense, even though it's slower.

@milahu
Copy link
Contributor

milahu commented Mar 13, 2021

as workaround i propose patch #1686 where we allow to pass options to recursive-copy

ventyConfig.addPassthroughCopy("node_modules/@fontsource/noto-sans", { expand: true });

eleventyConfig.addPassthroughCopy({
  'posts/**': 'blog',
}, {
  filter: path => (path.slice(-3) != '.md')
});

@tcurdt
Copy link

tcurdt commented Nov 18, 2021

Stumbled over this yet again. The only way I was able to make this work was to use templateFormats and have them default to a pass through copy. addPassthroughCopy and .eventignore are still not working together. Not nice.

@baxline
Copy link

baxline commented Apr 15, 2022

I found this to be a problem/annoyance as well. It doesn't block development, but creates noise in the console and a messy output folder.

My workaround was to use a glob pattern like this:
eleventyConfig.addPassthroughCopy("src/**/*.jpg");

An important difference between my project and the example is that I am not using an .eleventyignore file. My src/ and node_modules/ directories are in my .gitignore file. (The docs state "Note that any paths listed in your project’s .gitignore file are automatically ignored—you don’t need to duplicate them to your .eleventyignore file." [1])

I am calling out node_modules because it is NOT being copied over, as expected.

References:

  1. https://www.11ty.dev/docs/ignores/

@zachleat
Copy link
Member

Sorry for the super-late reply here, going through some ignores logic today and realizing we are missing some clarity.

Here’s how it works now (warts and all):

  • The addPassthroughCopy configuration API method bypasses any and all ignores in your project. You can copy anything.
  • The older, legacy, likely soon to be deprecated Passthrough by File Extension method does respect project ignores.

I think changing the default to add ignore support into addPassthroughCopy would not be a welcome change. This is often used to copy things from node_modules into the output folder.

All of that said, maybe another opt-in (instead of changing the default) for this is warranted given the confusion here!

@zachleat
Copy link
Member

Also #2461

@zachleat
Copy link
Member

Excellent counterpoint (“why is _site not ignored?”) from @SuaYoo here: #2461 (comment)

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

No branches or pull requests

8 participants