@@ -222,7 +222,7 @@ def _raise(e):
222222
223223def compile_dirname (
224224 search_path , output_path , output_style , source_comments , include_paths ,
225- precision , custom_functions , importers
225+ precision , custom_functions , importers , custom_import_extensions
226226):
227227 fs_encoding = sys .getfilesystemencoding () or sys .getdefaultencoding ()
228228 for dirpath , _ , filenames in os .walk (search_path , onerror = _raise ):
@@ -240,6 +240,7 @@ def compile_dirname(
240240 s , v , _ = _sass .compile_filename (
241241 input_filename , output_style , source_comments , include_paths ,
242242 precision , None , custom_functions , importers , None ,
243+ custom_import_extensions ,
243244 )
244245 if s :
245246 v = v .decode ('UTF-8' )
@@ -292,6 +293,9 @@ def compile(**kwargs):
292293 :type custom_functions: :class:`set`,
293294 :class:`collections.abc.Sequence`,
294295 :class:`collections.abc.Mapping`
296+ :param custom_import_extensions: optional extra file extensions which
297+ allow can be imported, eg. ``['.css']``
298+ :type custom_import_extensions: :class:`list`, :class:`tuple`
295299 :param indented: optional declaration that the string is Sass, not SCSS
296300 formatted. :const:`False` by default
297301 :type indented: :class:`bool`
@@ -332,6 +336,9 @@ def compile(**kwargs):
332336 :type custom_functions: :class:`set`,
333337 :class:`collections.abc.Sequence`,
334338 :class:`collections.abc.Mapping`
339+ :param custom_import_extensions: optional extra file extensions which
340+ allow can be imported, eg. ``['.css']``
341+ :type custom_import_extensions: :class:`list`, :class:`tuple`
335342 :param importers: optional callback functions.
336343 see also below `importer callbacks
337344 <importer-callbacks_>`_ description
@@ -374,6 +381,9 @@ def compile(**kwargs):
374381 :type custom_functions: :class:`set`,
375382 :class:`collections.abc.Sequence`,
376383 :class:`collections.abc.Mapping`
384+ :param custom_import_extensions: optional extra file extensions which
385+ allow can be imported, eg. ``['.css']``
386+ :type custom_import_extensions: :class:`list`, :class:`tuple`
377387 :raises sass.CompileError: when it fails for any reason
378388 (for example the given Sass has broken syntax)
379389
@@ -584,6 +594,14 @@ def _get_file_arg(key):
584594 'not {1!r}' .format (SassFunction , custom_functions )
585595 )
586596
597+ _custom_exts = kwargs .pop ('custom_import_extensions' , []) or []
598+ if not isinstance (_custom_exts , (list , tuple )):
599+ raise TypeError (
600+ 'custom_import_extensions must be a list of strings '
601+ 'not {}' .format (type (_custom_exts ))
602+ )
603+ custom_import_extensions = [ext .encode ('utf-8' ) for ext in _custom_exts ]
604+
587605 importers = _validate_importers (kwargs .pop ('importers' , None ))
588606
589607 if 'string' in modes :
@@ -597,7 +615,7 @@ def _get_file_arg(key):
597615 _check_no_remaining_kwargs (compile , kwargs )
598616 s , v = _sass .compile_string (
599617 string , output_style , source_comments , include_paths , precision ,
600- custom_functions , indented , importers ,
618+ custom_functions , indented , importers , custom_import_extensions ,
601619 )
602620 if s :
603621 return v .decode ('utf-8' )
@@ -613,7 +631,7 @@ def _get_file_arg(key):
613631 s , v , source_map = _sass .compile_filename (
614632 filename , output_style , source_comments , include_paths , precision ,
615633 source_map_filename , custom_functions , importers ,
616- output_filename_hint ,
634+ output_filename_hint , custom_import_extensions ,
617635 )
618636 if s :
619637 v = v .decode ('utf-8' )
@@ -631,6 +649,7 @@ def _get_file_arg(key):
631649 s , v = compile_dirname (
632650 search_path , output_path , output_style , source_comments ,
633651 include_paths , precision , custom_functions , importers ,
652+ custom_import_extensions
634653 )
635654 if s :
636655 return
0 commit comments