Eleventy: Files in addPassthroughCopy with glob not ignored with .eleventyignore

Created on 29 Apr 2020  ยท  2Comments  ยท  Source: 11ty/eleventy

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)
bug

Most helpful comment

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.

All 2 comments

Same issue as #1252 ?

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.

Was this page helpful?
0 / 5 - 0 ratings