2727
2828
2929def build_directory (sass_path , css_path , output_style = 'nested' ,
30- _root_sass = None , _root_css = None ):
30+ _root_sass = None , _root_css = None , strip_extension = False ):
3131 """Compiles all Sass/SCSS files in ``path`` to CSS.
3232
3333 :param sass_path: the path of the directory which contains source files
@@ -58,6 +58,8 @@ def build_directory(sass_path, css_path, output_style='nested',
5858 if name [0 ] == '_' :
5959 # Do not compile if it's partial
6060 continue
61+ if strip_extension :
62+ name , _ = os .path .splitext (name )
6163 css_fullname = os .path .join (css_path , name ) + '.css'
6264 css = compile (filename = sass_fullname ,
6365 output_style = output_style ,
@@ -73,7 +75,8 @@ def build_directory(sass_path, css_path, output_style='nested',
7375 subresult = build_directory (sass_fullname , css_fullname ,
7476 output_style = output_style ,
7577 _root_sass = _root_sass ,
76- _root_css = _root_css )
78+ _root_css = _root_css ,
79+ strip_extension = strip_extension )
7780 result .update (subresult )
7881 return result
7982
@@ -201,7 +204,8 @@ def build(self, package_dir, output_style='nested'):
201204 css_path = os .path .join (package_dir , self .css_path )
202205 css_files = build_directory (
203206 sass_path , css_path ,
204- output_style = output_style
207+ output_style = output_style ,
208+ strip_extension = self .strip_extension
205209 ).values ()
206210 return frozenset (os .path .join (self .css_path , filename )
207211 for filename in css_files )
0 commit comments