Search code examples
sassrubygemsjekyllgithub-pages

How to get jekyll to compile my sass when it changes?


I have a github pages site using the jekyll cayman theme, and I set up a sass stylesheet at assets/css/style.scss

Its contents begin:

---
# Front matter comment to ensure Jekyll properly reads file.
---
//DON'T DELETE THE ABOVE

@import "jekyll-theme-cayman";

and then I have the rest of my sass.

I then run bundle exec jekyll serve.

This used to work to start a server, and watch changes to the sass file and compile them to _site/assets/css/style.css.

I can see that it is picking up that there are changes in the sass file - the console logs: Regenerating: 1 file(s) changed at 2022-10-28 21:22:54 assets/css/style.scss - but nothing gets output to the style.css file. I've tried running bundle exec jekyll serve --watch.

That no longer works, and I'm not sure why. I noticed when I tried to run this for the first time in a while, it complained about nokogiri, so I ran bundle install - maybe that messed things up?


Solution

  • Try bundle exec jekyll clean && bundle exec jekyll serve or one command after the other. Clean removes files and cleans Sass and Jekyll caches. See https://jekyllrb.com/docs/usage/