sigal icon indicating copy to clipboard operation
sigal copied to clipboard

minify CSS/Javascript resources on gallery build

Open anarcat opened this issue 7 years ago • 3 comments

This is a followup to the conversation we had in https://github.com/saimn/sigal/pull/280#issuecomment-355091912 about how it was somewhat difficult to make changes to the theme, because a change need to be propagated around a lot:

  1. the original sigal source
  2. the minified version of the CSS/JS file
  3. the installed sigal program
  4. the installed gallery

Steps 3 to 4 are natural and easy: just call sigal build, no problem there. Between step 1 to 3 (jumping over 2 for now) is expected: this is a deployment issue and I can deal with that. What I find annoying (and it makes the deployment issue worse) is that sigal actually ships minified copies of Javascript and CSS code in the original source code.

In #281 this was removed from photoswipe, but I think that could be extended to all themes, which should ship only non-minified version of the static assets. Then the build command could take care of minifying the code, maybe through a plugin like the compress asset plugin (proposed in #288) which could be extended to support minification (or just a standalone plugin).

Yes, this means an extra run-time dependency, but I don't think it's that big of a deal. Minifiers are fast, and that needs to be done only once: makefile-like timestamp checks can be used to avoid rebuilding unchanged files.

The new development process would be simpler:

  1. modify the source
  2. pip install (or just run from source)
  3. build the gallery

We could even have galleries without any minification that would allow developing directly on the static assets, which would be even faster: no build, just edit the source. This could be bridged with web browser development consoles so that we would end up having a realtime development environment. Checking the files back into version control would then be simply a matter of copying them back when we're happy with the changes.

anarcat avatar Jan 31 '18 15:01 anarcat

oh, and this would make debian packaging (#200) easier as well of course. :)

anarcat avatar Jan 31 '18 15:01 anarcat

I am almost convinced about removing this manual minification for all themes, and doing this in a plugin. On issue for concatenation will be to know which files to concatenate, in which order, and how to modify the HTML template. Maybe not so easy to do properly...

saimn avatar Feb 06 '18 23:02 saimn

if we don't do this in a plugin and instead minify (on the fly, when needed, but minify) then the HTML templates can still link to the minified files without requiring any changes... I don't really see why we would ship (in the built gallery) non-minified files, so I would say that this shouldn't be a plugin...

anarcat avatar Feb 21 '18 17:02 anarcat