getpelican / pelican-plugins

Collection of plugins for the Pelican static site generator
Other
1.39k stars 856 forks source link

[new_plugin] minification #1362

Open dArignac opened 2 years ago

dArignac commented 2 years ago

Hi there,

I have a plugin that does minification of the HTML, CSS files as well as inline styles and javascript and would like to move it to here. I prepared the structure and setup according to your cookiecutter in my branch here: https://github.com/dArignac/pelican-minification/tree/5-add-to-pelican-plugins

Best, Alex

justinmayer commented 2 years ago

Hi Alexander. Thank you for reaching out. For my own education, would you please let me know how the plugin differs from the WebAssets plugin?

kernc commented 2 years ago

would you please let me know how the plugin differs from the WebAssets plugin?

Webassets doesn't minify HTML. And there is no good alternative (package css-html-js-minify, a dep of plugin css-html-js-minify, seems abandoned).

dArignac commented 2 years ago

As pointed out by @kernc, our plugin additionally minifies HTML. It does not do any of the webassets based capabilities as listed in the webassets plugin page (cache busting, spritemaps, data URIs).

kernc commented 2 years ago

Your implementation, however, depends on packages htmlmin and csscompressor, which haven't been touched in years.

nkr0 commented 1 year ago

@dArignac why do you only minify inline js and not js files in the build folder?

S1SYPHOS commented 1 year ago

@nkr0 .. because files in the build folder are not part of the (generated) HTML document

// Update: I had a quick look at the source .. yeah, it seems odd that external CSS files are minified (if enabled via CSS_MIN), but JS files aren't - I'd be interested to hear from you, @dArignac :grin:

dArignac commented 1 year ago

Howdy! It's been a while, thanks for your comments! I was now able to review your comments and to update the code.

@S1SYPHOS @nkr0 everything is now minified: JS, CSS, HTML files and inline CSS & JS @kernc I changed to https://github.com/wilsonzlin/minify-html for minification as the only lib. It's somewhat up to date.

S1SYPHOS commented 1 year ago

In the meantime I developed something on my own using a minifier written in Golang (using its Python bindings), but I guess I didn't release it to the public yet 😅

If I find the time, I'll gladly check out your changes, thanks for letting me know!

dArignac commented 11 months ago

Ok, not seeing this going anywhere, therefore closing my request.

justinmayer commented 11 months ago

Hey Alexander. Please accept my sincere apologies for the delay in getting back to you about your request. It has been a particularly busy period.

I would be happy to set up a separate repository for this plugin under the new Pelican Plugins organization so that we can collaborate on its development. I will update this issue by the end of next week with further details and next steps. How does that sound?

dArignac commented 11 months ago

Hi Justin, alright, thanks for picking it up again.

justinmayer commented 11 months ago

Certainly! To that end, would you be so kind as to add the following two usernames with Owner role to the PyPI project?

That way, once the repository has been set up, future releases can be published to PyPI via the same automated process as the other plugins under the Pelican Plugins organization.

dArignac commented 11 months ago

Sure, invites were sent.

justinmayer commented 11 months ago

Excellent. Thank you, Alexander! 😊

justinmayer commented 11 months ago

I have created the new repository under the Pelican Plugins organization. When doing so, it occurred to me that the “pelican-minification” name is a bit cumbersome and has problems with auto-correct, and that “minify” would be a cleaner, better name for the plugin. The pelican-minify namespace on PyPI was already taken, but the last release was in 2015 and was created by someone I know, so I asked if the Pelican community could take over that project name on PyPI. That request was kindly granted, so we now have the ability to publish to pelican-minify on PyPI.

Following is a proposed list of steps that will eventually lead to publishing version 2.0.0 to PyPI from the plugin’s new repository:

How does that sound? Any steps I should add to this list?

dArignac commented 11 months ago

Hi Justin,

that sounds good, cannot think of any additional action item. Will review the PR then. Thanks a lot for doing the heavy lifting and moving everything over 👍🏻

justinmayer commented 11 months ago

My pleasure. I just re-worked the commits in that PR's migrate branch in order to better preserve the committer/date metadata. I look forward to your comments on the PR. 😊

dArignac commented 11 months ago

I'd work on the next open points, also need to make myself familiar with autopub.

justinmayer commented 11 months ago

For the next step in the process, it's probably easier for me to handle the release. All of the release publication machinery is already in place; it's just a question of deciding what to put in the release notes / change-log.

I will endeavor to finish that step later today. But once that is done, your help with the last two steps would be helpful and much appreciated!

dArignac commented 11 months ago

I think the CHANGELOG.md needs to be renamed for autopub. We could put that as release notes:

2.0.0
------------------

- restructured according to Pelican plugin guidelines and released under pelican-plugin organization
- Add `JS_MIN` setting and ability to minify JavaScript files
- Replace all minifiers with `minify_html`
justinmayer commented 11 months ago

Version 2.0.0 of the Minify plugin has been released 🎊

(There was a minor hiccup with the release automation due to some missing project metadata, but that should now be fixed.)

@dArignac: If you would be so kind as to publish a notice & link to the new repo/PyPI pages on the pelican-minification repository README, that would be wonderful.

dArignac commented 11 months ago

@justinmayer Notice was added.

justinmayer commented 11 months ago

Great! I don't know if there is an easy way to do the same for the README on the PyPI page. The only way I can think of would be to publish version 1.0.1 to that project so the notice you added to the repo's README is updated on the PyPI page. 🤔

dArignac commented 11 months ago

I will take care of this within the next days.

dArignac commented 11 months ago

A note was added to the new patch version of the old plugin: https://pypi.org/project/pelican-minification/