robwierzbowski / generator-jekyllrb

Supercharge Jekyll development with Yeoman. Yo, Jekyllrb!
BSD 3-Clause "New" or "Revised" License
595 stars 65 forks source link

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

Open oller opened 9 years ago

oller commented 9 years ago

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 9 years ago

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 }}