I am having a problem getting libsass to compile SASS files. I can get it to compile SCSS files just fine.
I have a Flask application and I've installed libsass and I am using the libsass binding sass. It works well but is missing some functionality - it can't compile SASS but it can compile SCSS. Here's what I did:
In my applicaiton.py file I have
from flask import Flask
import sass
app = Flask(__name__)
@app.route('/')
def hello_world():
return 'Hello World!'
if __name__ == '__main__':
sass.compile(dirname=('client/sass', 'client/css'), source_comments=True)
app.run()
My two test files are test_scss.scss
, which works:
$font-stack: Helvetica, sans-serif;
$primary-color: #333;
body {
font: 100% $font-stack;
color: $primary-color;
}
And test_sass.sass
:
$font-stack: Helvetica, sans-serif
$primary-color: #333
body
font: 100% $font-stack
color: $primary-color
The documentation says sass.complie
can take in SASS code but I can only get it to take SCSS code. That is, when I run my application, only the .scss
file gets compile to CSS. The directory structure of my applicaiton after sass.compile
runs is:
- client
- css
- app.css
- test_scss.css
- lib
- sass
- test_sass.sass
- test_scss.scss
- css
- server
- templates
- application.py
Someone suggested that I just rename the SASS file to something with a .scss
extension. Like test_sass.scss
:'
$font-stack: Helvetica, sans-serif
$primary-color: #333
body
font: 100% $font-stack
color: $primary-color
However, when I do this, I just get the following error:
src/web-internal/server/applicaiton.py", line 8, in <module>
sass.compile(dirname=('client/sass', 'client/css'), source_comments=True)
File "/usr/local/lib/python3.4/site-packages/sass.py", line 516, in compile
raise CompileError(v)
sass.CompileError: b"Error: top-level variable binding must be terminated by ';'\n on line 2 of src/web-internal/server/../client/sass/test_sass.scss\n>> $primary-color: #333\n ^\n"
I'd like to use SASS, and would perfer not to settle for SCSS. Does anyone have any suggestions? I feel like there is something in the sass documentation that I am missunderstanding.