如何使用python webassets编译bootstrap4scs?

2024-10-04 01:27:18 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图用pythonwebassets简单地编译bootstrap4,但是没有成功。现在,我只想在bootstrap/scss目录中执行此操作,这样路径问题就不那么重要了。在这个目录中,我添加了一个main.scss文件,其中有一行:

@import "bootstrap.scss";

我有一个名为test_scss.py的脚本,如下所示:

^{pr2}$

当我运行这个命令时,我会得到如下的错误跟踪:

Traceback (most recent call last):
  File "./test_scss.py", line 11, in <module>
    print(my_env['css_all'].urls())
  File "/Users/benlindsay/miniconda/lib/python3.6/site-packages/webassets/bundle.py", line 806, in urls
    urls.extend(bundle._urls(new_ctx, extra_filters, *args, **kwargs))
  File "/Users/benlindsay/miniconda/lib/python3.6/site-packages/webassets/bundle.py", line 765, in _urls
    *args, **kwargs)
  File "/Users/benlindsay/miniconda/lib/python3.6/site-packages/webassets/bundle.py", line 619, in _build
    force, disable_cache=disable_cache, extra_filters=extra_filters)
  File "/Users/benlindsay/miniconda/lib/python3.6/site-packages/webassets/bundle.py", line 543, in _merge_and_apply
    kwargs=item_data)
  File "/Users/benlindsay/miniconda/lib/python3.6/site-packages/webassets/merge.py", line 276, in apply
    return self._wrap_cache(key, func)
  File "/Users/benlindsay/miniconda/lib/python3.6/site-packages/webassets/merge.py", line 218, in _wrap_cache
    content = func().getvalue()
  File "/Users/benlindsay/miniconda/lib/python3.6/site-packages/webassets/merge.py", line 251, in func
    getattr(filter, type)(data, out, **kwargs_final)
  File "/Users/benlindsay/miniconda/lib/python3.6/site-packages/webassets/filter/sass.py", line 196, in input
    self._apply_sass(_in, out, os.path.dirname(source_path))
  File "/Users/benlindsay/miniconda/lib/python3.6/site-packages/webassets/filter/sass.py", line 190, in _apply_sass
    return self.subprocess(args, out, _in, cwd=child_cwd)
  File "/Users/benlindsay/miniconda/lib/python3.6/site-packages/webassets/filter/__init__.py", line 527, in subprocess
    proc.returncode, stdout, stderr))
webassets.exceptions.FilterError: scss: subprocess returned a non-success result code: 65, stdout=b'',
stderr=b'DEPRECATION WARNING: Importing from the current working directory will
not be automatic in future versions of Sass.  To avoid future errors, you can add it
to your environment explicitly by setting `SASS_PATH=.`, by using the -I command
line option, or by changing your Sass configuration options.

Error: Invalid CSS after "...lor}: #{$value}": expected "{", was ";"
        on line 4 of /Users/benlindsay/scratch/python/webassets/test-2/bootstrap/scss/_root.scss
        from line 11 of /Users/benlindsay/scratch/python/webassets/test-2/bootstrap/scss/bootstrap.scss
        from line 1 of standard input
  Use --trace for backtrace.

如果我按照说明操作并设置环境变量SASS_PATH=.,这将消除错误消息的这一部分,但仍然会得到错误消息

Error: Invalid CSS after "...lor}: #{$value}": expected "{", was ";"
        on line 4 of /Users/benlindsay/scratch/python/webassets/test-2/bootstrap/scss/_root.scss
        from line 11 of /Users/benlindsay/scratch/python/webassets/test-2/bootstrap/scss/bootstrap.scss
        from line 1 of standard input
  Use --trace for backtrace.

我还不太了解SCSS语法,但我敢打赌这是我做错了什么,而不是引导SCSS中的错误。如果你能想到我做错了什么,我将不胜感激。在


Tags: ofinpytestlibpackageslinesite