robwierzbowski/generator-jekyllrb

Liquid template flag available for app/dist (dev/production) build?

oller opened this issue · 1 comments

oller commented

Hi there,

I'm doing a bit of work integrating the lazySizes responsive image plugin into my jekyll site initially setup with this great generator.

To do this, I need to do a bit of string manipulation on image paths, to add in a {width} variable into the path. This works great on build, when viewing the production site from the /dist dir. However this breaks the paths when just using grunt serve which still references assets from the app dir. I'd rather not build all these images constantly just for dev, so the ability to toggle this via a flag would be ideal.

Is there a way I can get a flag into a liquid template, so jekyll would be aware of its environment, building a production build or not, and I can use this to alter the path to the image accordingly? or should I be looking to try and solve this in grunt?

Any suggestions appreciated, cheers!

oller commented

Aha, I've added the following values and it seems to work. The build yml file overriding the regular config yml file when I do a full grunt build

config.yml

production: false

config.build.yml

production: true

These can be accessed globally with, and seem to reflect the environment correctly.

{{ site.production }}