Optimisation Mode on Hammer


There’s no question, that the Hammer Optimisation mode needs a bit of an overhaul and I’m planning on tackling that, probably after the summer.

In the meantime, I’d like to start a topic in relation to Optimisation mode, to document how it currently works and open the discussion about what we’d like to see in the future.

Current Implementation

You may be familiar with the Optimise Mode in Hammer. In principal, it’s a fantastically simple way to compress your site for production.

Currently, optimise mode will simply minify and compress your css and js files, within your Build folder.

And replaces the assets paths in your code to point to these new optimised files.

Current Issues

As you can see above, this actually does work. At least for this relatively simple site.

But there are some known issues when dealing with the up-to-date Sass import mechanisms:

@RECODESIGN_Rich says:

Yeah I get the Optimised Build Error too. Sometimes it doesn’t throw an error, but when it “works”, there are anomalies with my CSS. I have found one anomaly and a fix.

I use multiple SCSS files and an application.scss to compile them all together. However, if I’m using a 3rd party CSS file, this is usually listed at the end of the imports as filename.css.

When the optimised compiler does its thing, it puts any CSS @imports at the top (which you have to do due to CSS rules) and then it puts the one line of compiled SCSS after it.

The anomaly is that the optimised compiler strips a semi-colon out after the @import rule. Here is a snippet of the CSS at the top of my optimised file:

@import url(css/swiper.min.css)@keyframes introColours{0%,……….etc

This causes multiple problems later on in the optimised CSS file. A fix is to just give everything a .scss file extension.

  1. I wonder, why doesn’t the compiler merge all scss and css files into one line and in the order declared in the @import list?
  2. The optimised compiler deletes my javascript folder at the end of optimisation, but not the CSS one. How come?

Sorry if this has already been noted.

@Miktirr says:

These optimization errors really are a bummer. :confused: 30–40 seconds Macbook Pro’s fans yelling – and then a fail on a project that builds fine without optimization.

Future Opportunities

Some of the things that have already been requested for Optimization mode: