Autoloading Sass in Sinatra
You can use style injection when developing sinatra apps, allowing you to see css/sass changes without refreshing your browser.
This is especially helpful when doing responsive design, since you can have different sized browser windows open at the same time and see how each changes affects a particular viewport.
Getting Set Up
- Clone and bundle a preconfigured sample application
- Install the appropriate livereload browser extension - there's one for Chrome, Firefox, and Safari
- From the public/css directory, run
sass --watch style.scss:style.css
(this command could change as more sass files are added to the project) - From the project root directory, run
guard
- From the project root directory, run
rackup
- You're done! Now anytime you save a change
style.scss
, thestyle.css
file gets updated and your browser will show its changes without reloading the page.
There's a more detailed version of this writeup on the project readme. Special thanks to Matt Brictson's excellent blog post, without which this tip would not be possible.
Written by Alex Lau
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Css
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#