Fixed sassassets module running compile from the wrong workingdir

This commit is contained in:
Sebastian 2016-11-11 14:48:32 +01:00
parent c868d2f30f
commit 51d102ccd9
1 changed files with 7 additions and 1 deletions

View File

@ -31,13 +31,19 @@ class SassAssets(MessageMixin, RenderMixin, AssetsMixin):
def compile_file(self, source_path, dest_path):
print "Compiling %s to %s" % (source_path, dest_path)
source_dir = os.path.dirname(source_path)
original_dir = os.getcwd()
sass_file = open(source_path, 'r')
css_file = open(dest_path, 'w')
os.chdir(source_dir)
sass_string = sass_file.read().decode('utf-8')
css_string = sass.compile_str(sass_string)
css_file.write(css_string.encode('utf-8'))
os.chdir(original_dir)
sass_file.close()
css_file.close()