rojcyk rojcyk - 5 months ago 21x
Ruby Question causes Sass::SyntaxError on @import

I'm writing my own static site generator in ruby and I'm in the process of adding Sass compiler to my code.

def compile_sass
# system 'sass _sass/styles.scss styles.css'
options = {
syntax: :scss,
style: :compressed
render ='_sass/styles.scss'), options).render
File.write('style.css', render)

But problem occurs when the styles.scss file has @import in it. Causing

(sass):1: File to import not found or unreadable: variables. (Sass::SyntaxError)

Both SCSS files are located in _sass folder, main script in root, and compile_sass is located in _generator. But when I uncomment the system call and comment the rest, everything works as expected.


@import 'variables';

html {
background-color: red;


body {
background-color: blue;

I tried almost everything, checked how to import stuff, looked at the documentation, but I can't find anything that would helped me find and define the problem.


Turns out I had to load all _sass/*.scss files into Sass::Engine like this:

Sass::Engine::DEFAULT_OPTIONS[:load_paths].tap do |load_paths|
  load_paths << '_sass'