11ty / eleventy

A simpler site generator. Transforms a directory of templates (of varying types) into HTML.
https://www.11ty.dev/
MIT License
17.32k stars 495 forks source link

Nested subfolder .eleventyignore files #2608

Closed AlexNodex closed 1 year ago

AlexNodex commented 2 years ago

Is your feature request related to a problem? Please describe. It would be great if there could be an .eleventyignore read in all processed folders to see what needs ignoring in that folder (recursive)

We're currently trying to modularise and theme eleventy to make it a much easier developer friendly way to add themes/modules to the platform - simply by cloning a theme / module in to a directory.

The trouble at the moment is that in its non modular state all partials / layouts are processed and turned in to files. Obviously to get round this we've added the path to the .eleventyignore file in the project root but this isn't ideal as it would mean editing this file every time a module / theme is added to a project.

Describe the solution you'd like A much better solution would be for themes/modules etc to be able to manage their own (opinionated) .eleventyignore file inside the root folder for the module / theme ....

// src/modules/blog/.eleventyignore
path/to/partials/*.njk // do not process these files

Describe alternatives you've considered Currently we're editing the ignore file in the root of the project, however, as mentioned this is less than ideal. I suppose another way would be to rename the files to something that eleventy doens't support such as file.njk.inc or something but this feels hacky and could break easily in the future if eleventy were to suddenly start supporting !

j-f1 commented 2 years ago

Could you implement a plugin that adds the appropriate directories to eleventyConfig.ignores?

mortendk commented 2 years ago

+1 for this i have been trying a ton of different ways of having multiple "themes" added I ended up having other themes outside of the /src/ folder and then addes them in 11ty have a tendency to take everything and the kitchen sink, its a step more when setting up but "works"

a /themes/[themename]/.eleventyignore i tried the other way around with eleventy.config.js

eleventyConfig.ignores.add("src/themes/");
eleventyConfig.ignores.remove("src/themes/[whatheverthemefolderiwantobeactive]");

but then the theme during eleventy --serve only runs once and dont pick up changes

zachleat commented 2 years ago

just dipping in here to say @mortendk you can use the eleventy.before or eleventy.after events to run something with every build https://www.11ty.dev/docs/events/

mortendk commented 2 years ago

@zachleat cool learning new every day

zachleat commented 1 year ago

I do think the programmatic API for ignores is the way forward here but I will add this one to the enhancement queue if folks want to upvote it!

https://www.11ty.dev/docs/ignores/#configuration-api

This repository is now using lodash style issue management for enhancements. This means enhancement issues will now be closed instead of leaving them open.

View the enhancement backlog here. Don’t forget to upvote the top comment with 👍!