Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SCSS filter runs command sass without --scss #537

Open
kernc opened this issue Jul 19, 2020 · 2 comments
Open

SCSS filter runs command sass without --scss #537

kernc opened this issue Jul 19, 2020 · 2 comments

Comments

@kernc
Copy link
Contributor

kernc commented Jul 19, 2020

Given the following mwe SCSS file:

/* /tmp/file.scss: */
$baseFontFamily : "Droid Sans", sans-serif;

body {
  font: 14px/1.5 $baseFontFamily;
}

the following script snippet:

# webassets_bug.py:
from webassets import Bundle, Environment

bundle = Bundle('/tmp/file.scss', filters='scss', output='/tmp/out.css')
env = Environment(directory='/tmp/')
env.register('css', bundle)

print(bundle.urls())

fails with:

$ python webassets_bug.py
Traceback (most recent call last):
  File "webassets_bug.py", line 7, in <module>
    print(bundle.urls())
  File "/usr/lib/python3.7/site-packages/webassets/bundle.py", line 833, in urls
    urls.extend(bundle._urls(new_ctx, extra_filters, *args, **kwargs))
  File "/usr/lib/python3.7/site-packages/webassets/bundle.py", line 768, in _urls
    *args, **kwargs)
  File "/usr/lib/python3.7/site-packages/webassets/bundle.py", line 620, in _build
    force, disable_cache=disable_cache, extra_filters=extra_filters)
  File "/usr/lib/python3.7/site-packages/webassets/bundle.py", line 544, in _merge_and_apply
    kwargs=item_data)
  File "/usr/lib/python3.7/site-packages/webassets/merge.py", line 280, in apply
    return self._wrap_cache(key, func)
  File "/usr/lib/python3.7/site-packages/webassets/merge.py", line 222, in _wrap_cache
    content = func().getvalue()
  File "/usr/lib/python3.7/site-packages/webassets/merge.py", line 255, in func
    getattr(filter, type)(data, out, **kwargs_final)
  File "/usr/lib/python3.7/site-packages/webassets/filter/sass.py", line 148, in input
    self._apply_sass(_in, out, os.path.dirname(source_path))
  File "/usr/lib/python3.7/site-packages/webassets/filter/sass.py", line 142, in _apply_sass
    return self.subprocess(args, out, _in, cwd=child_cwd)
  File "/usr/lib/python3.7/site-packages/webassets/filter/__init__.py", line 529, in subprocess
    stderr.decode('utf-8').strip()))
webassets.exceptions.FilterError: scss: subprocess returned a non-success result code: 65, stdout=, stderr=(sass):3: Invalid CSS after "...ns", sans-serif": expected expression (e.g. 1px, bold), was ";" (Sass::SyntaxError)
	from /usr/lib/ruby/vendor_ruby/sass/scss/parser.rb:1278:in `expected'
	from /usr/lib/ruby/vendor_ruby/sass/script/lexer.rb:231:in `expected!'
	from /usr/lib/ruby/vendor_ruby/sass/script/parser.rb:762:in `assert_done'
	from /usr/lib/ruby/vendor_ruby/sass/script/parser.rb:69:in `parse'
	from /usr/lib/ruby/vendor_ruby/sass/script/parser.rb:228:in `parse'
	from /usr/lib/ruby/vendor_ruby/sass/script.rb:27:in `parse'
	from /usr/lib/ruby/vendor_ruby/sass/engine.rb:1177:in `parse_script'
	from /usr/lib/ruby/vendor_ruby/sass/engine.rb:783:in `parse_variable'
	from /usr/lib/ruby/vendor_ruby/sass/engine.rb:651:in `parse_line'
	from /usr/lib/ruby/vendor_ruby/sass/engine.rb:540:in `build_tree'
	from /usr/lib/ruby/vendor_ruby/sass/engine.rb:559:in `block in append_children'
	from /usr/lib/ruby/vendor_ruby/sass/engine.rb:558:in `each'
	from /usr/lib/ruby/vendor_ruby/sass/engine.rb:558:in `append_children'
	from /usr/lib/ruby/vendor_ruby/sass/engine.rb:417:in `_to_tree'
	from /usr/lib/ruby/vendor_ruby/sass/engine.rb:290:in `render'
	from /usr/lib/ruby/vendor_ruby/sass/exec/sass_scss.rb:396:in `run'
	from /usr/lib/ruby/vendor_ruby/sass/exec/sass_scss.rb:63:in `process_result'
	from /usr/lib/ruby/vendor_ruby/sass/exec/base.rb:52:in `parse'
	from /usr/lib/ruby/vendor_ruby/sass/exec/base.rb:19:in `parse!'
	from /usr/bin/sass:8:in `<main>'
@kernc
Copy link
Contributor Author

kernc commented Jul 19, 2020

A solution appears to be to append --scss if binary is sass and self.use_scss:

args = [self.binary or 'sass',
'--stdin',
'--style', self.style or 'expanded']
if not self.use_scss:
args.append("--indented")

@kernc
Copy link
Contributor Author

kernc commented Jul 19, 2020

The switch was once present and lost in #523.

kernc added a commit to kernc/pelican-plugins that referenced this issue Jul 19, 2020
kdeldycke pushed a commit to pelican-plugins/webassets that referenced this issue Dec 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant