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

not compressing some files node_modules? #10

Open
agowa opened this issue Sep 5, 2021 · 1 comment
Open

not compressing some files node_modules? #10

agowa opened this issue Sep 5, 2021 · 1 comment

Comments

@agowa
Copy link

agowa commented Sep 5, 2021

I'm also using the jekyll-node-module plugin and it appears that files copied by that plugin aren't compressed. Even though that plugin is executed first.

This plugin correctly generates the compressed files for everything except the files that are copied (e.g. /assets/webfonts). At least the svg and eot files in there should be compressed, but currently aren't. No such problem with the files that module places in /assets/js or /assets/css.
Also if I place another svg file manually in that location e.g. /assets/webfonts/test.svg the gzip files are created correctly, but only for that one specific file. The files that the module copied there are still ignored.

When using --verbose I can also see that the copying happens before jekyll-gzip is invoked.

_config.yml:

plugins:
  - jekyll-node-module
  - jekyll-minifier
  - jekyll-brotli
  - jekyll-gzip

node_modules:
  assets:
    js: assets/js
    css: assets/css
  copy:
    - source: '@fortawesome/fontawesome-free/webfonts/'
      target: assets/webfonts
@philnash
Copy link
Owner

philnash commented Sep 6, 2021

jekyll-gzip (and jekyll-brotli) both use the Jekyll site post_write hook and use the site object and the method each_static_file to compress all the static files generated by Jekyll. The jekyll-node-module plugin seems to copy across the static files, but they aren't added to the site object at all, so this plugin doesn't know about them.

The plugins do expose a compress_directory method that can be used to iterate over the files in a directory and compress them. This is used within the plugin to detect whether the jekyll-assets plugin is present and then register with that plugin's after_write hook to compress the results.

I imagine something similar could be done for jekyll-node-module. You might be able to do so within your own application, and I'd be happy to take pull requests to add the behaviour if it can be generalised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants