Halo-Lab / eleventy-packages

Monorepo for all Eleventy plugins.
24 stars 1 forks source link

compression - How to ignore files #45

Open peekxc opened 1 month ago

peekxc commented 1 month ago

How can I add files/paths to ignore?

Since the compression works on the output directory---not on the input-to-output cascade eleventy performs---it seems to be oblivious to paths added via eleventyConfig.ignores.add. For example, if I have a custom route leading to a file that doesn't exist on my local machine:

...
<script defer src="/_vercel/insights/script.js"> </script>
...

The compression plugin detects the path and tries to compress it:

10:13:21 AM -> Icons: Start to compress "docs/_vercel/insights/script.js" file 🆙
 10:13:21 AM -> Icons: Error: ENOENT: no such file or directory, open '/Users/mpiekenbrock/peekxc.github.io/docs/_vercel/speed-insights/script.js'
Error: ENOENT: no such file or directory, open '/Users/mpiekenbrock/peekxc.github.io/docs/_vercel/speed-insights/script.js'
    at async open (node:internal/fs/promises:641:25)
    at async Object.readFile (node:internal/fs/promises:1254:14)
    at async w (/Users/mpiekenbrock/peekxc.github.io/node_modules/eleventy-plugin-compress/index.js:1:1480)
    at async Promise.all (index 4)
    at async Promise.all (index 0)
    at async A (/Users/mpiekenbrock/peekxc.github.io/node_modules/eleventy-plugin-compress/index.js:1:2424)
    at async Object.<anonymous> (/Users/mpiekenbrock/peekxc.github.io/node_modules/eleventy-plugin-compress/index.js:1:2947)
    at async Template.runTransforms (/Users/mpiekenbrock/.nvm/versions/node/v18.1.0/lib/node_modules/@11ty/eleventy/src/Template.js:514:15)
    at async Template.renderPageEntry (/Users/mpiekenbrock/.nvm/versions/node/v18.1.0/lib/node_modules/@11ty/eleventy/src/Template.js:799:15)
    at async /Users/mpiekenbrock/.nvm/versions/node/v18.1.0/lib/node_modules/@11ty/eleventy/src/Template.js:822:21 💥

But there is no such file, so this just floods the output with errors.

Edit: seems related if not identical to #8

Kapelianovych commented 2 days ago

Hello. Currently there is no way to ignore files or specifically ensure that some files will be compressed. Besides these plugins were created for Eleventy 0.12-13 if I remember correctly, so we need to update them for sure.