philhawksworth / netlify-plugin-minify-html

26 stars 8 forks source link

Plugin minifies only one html #5

Closed technusm1 closed 4 years ago

technusm1 commented 4 years ago

Hi, I am presently trying to setup this plugin with my personal blog written in Jekyll and hosted at Netlify. Here's a screenshot of some of my build settings:

image

I installed your plugin via the Plugins section UI and then used the following netlify.toml configuration, since I want to minify files only in production context:

[[plugins]]
  package = "netlify-plugin-minify-html"

  [plugins.inputs]
    contexts = [
      'production'
    ]

  [plugins.inputs.minifierOptions]
    removeComments = true
    collapseWhitespace = true

Here's a part of today's deployment log to give a basic idea about the blog file structure:

4:49:07 PM:            Writing: /opt/build/repo/_site/about/index.html
4:49:07 PM:            Writing: /opt/build/repo/_site/index.html
4:49:07 PM:            Writing: /opt/build/repo/_site/tags/index.html
4:49:07 PM:            Writing: /opt/build/repo/_site/assets/css/main.css
4:49:07 PM:            Writing: /opt/build/repo/_site/assets/js/lunr/lunr-en.js
4:49:07 PM:            Writing: /opt/build/repo/_site/assets/js/lunr/lunr-gr.js
4:49:07 PM:            Writing: /opt/build/repo/_site/assets/js/lunr/lunr-store.js
4:49:07 PM:            Writing: /opt/build/repo/_site/page2/index.html
4:49:07 PM:            Writing: /opt/build/repo/_site/sitemap.xml
4:49:07 PM:            Writing: /opt/build/repo/_site/robots.txt
4:49:07 PM:            Writing: /opt/build/repo/_site/feed.xml
4:49:07 PM:            Writing: /opt/build/repo/_site/assets/css/main.css.map
4:49:07 PM:            Writing: /opt/build/repo/_site/hello-world.html
4:49:07 PM:            Writing: /opt/build/repo/_site/installation-arch.html

So far, the plugin only minifies the first file /opt/build/repo/_site/about/index.html and nothing else. Could you please clarify if there is any option I may have missed, or perhaps, installed the plugin incorrectly?

Here's the main blog for reference: https://maheepk.net. The file above translates to the following URL: https://maheepk.net/about, in case you need to check something.

Thank you for your hard work. 😄

philhawksworth commented 4 years ago

Hmm. Let me explore. Thanks for reporting this, @mkathuri !

technusm1 commented 4 years ago

Just noticed that netlify keeps on picking up version 0.2.2. Is there any way to force it to pickup the latest version? I can report back on the issue after testing with latest version if there are any old issues which might have lead to this problem.

I tried cleaning the cache and deploying and also modified netlify.toml to trigger a deployment with and without the plugin. Still seems to pick 0.2.2.

philhawksworth commented 4 years ago

When you commit a change to your package.json file (where this version should be specified) Netlify should automatically invalidate your build cache and install the new versions of your dependencies.

Can you ensure that you have committed and pushed an update t your package.json file?

technusm1 commented 4 years ago

@philhawksworth the issue is finally resolved. I didn't have a package.json file in my blog. However, per your suggestion, I created a package.json file and added the plugin version 0.2.3 to devDependencies. This finally forced netlify to pick the correct version and all my woes are now gone. It is minifying all the files correctly as per expectations.

Perhaps it would be better if one could specify plugin versions in the netlify.toml file itself, rather than going with a package.json file. 😄

Thanks for all the help and hard work. 👍

philhawksworth commented 4 years ago

Hooray!

Without a package.json Netlify would not be able to track and install your build dependencies, so it's good that you've now added that.

I'll keep the management of the dependency versions in the package.json rather than adding it to the netlify.toml, since that is a convention and mechanism used widely and reaching far beyond Netlify.

Happy to hear this is working as expected. Thanks for updating this issue with the info.