-
Notifications
You must be signed in to change notification settings - Fork 1
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-plugin-compress] Empty brotli file #42
Comments
Hello @eitchtee . Thank you for contacting us. The problem is that you create the js script through eleventy, and eleventy writes the files after all the plugins have worked. That is, the situation arises, the first time you build, the file has not yet been created and an error occurs. And for the second build, the file will already be there - that's why there is no error for the second build. Accordingly, in relation to this information, the content will also be recorded incorrectly. Do you really need to create a js file through njk as an eleventy template ? If you are not critical, then you can not use templates for generating files that will be compressed yet. |
I suppose this is a precedence problem, something like the layout that uses the js file is built, the plugins tries to compress the scripts mentioned in this layout, which doesn't exist at the time, and them 11ty builds the js file from the template (too late now), right? The hack for building the js files from a njk template came from here 11ty/eleventy#344 (comment), as at the time I needed a way for 11ty to process the files for a custom transform that minified it, as a PassthroughCopy wouldn't allow me to do it. After some research I found a way of doing it within the addPassthroughCopy function.
Which, at least from my tests, seems to have completely fixed the problem. Not sure if possible, but perhaps the plugin could attach to Thank you very much for taking the time to reply and great work! |
Hi there,
I've stumbled upon a very weird bug.
In my setup I have a .njk file that includes a JS script so I'm able to minify these files within Eleventy using a transform, without needing other tools
And these javascript files are them added to my layout based on a condition set on the front matter
I've not been able to pinpoint exactly what causes the problem, but when building my site I get a broken brotli file with
;
as it's only content.I've setup a minimal example to help debug.
demo.zip
A few things worth noting:
Error: ENOENT: no such file or directory, open '[.....]\demo\public\js\testing.js' 💥
on the first run, but the plugin is already the last thing on the .eleventy.js file.The text was updated successfully, but these errors were encountered: