当前位置: 代码迷 >> python >> 使用Django-pipeline从基础站点的SCSS文件构建CSS时出现RuntimeError
  详细解决方案

使用Django-pipeline从基础站点的SCSS文件构建CSS时出现RuntimeError

热度:67   发布时间:2023-06-13 16:45:57.0

我的问题与在同一上下文中。 我正在尝试将foundationscss编译为css 问题是我遇到以下RuntimeError

/home/hakim/.gem/ruby/2.4.0/gems/sass-3.4.23/lib/sass/exec/sass_scss.rb:287:in `watch_or_update': File /home/hakim/github/myquotes/static/quotes/app.css doesn't exist. (RuntimeError)
    Did you mean: sass --update /home/hakim/github/myquotes/static/quotes/app.scss:/home/hakim/github/myquotes/static/quotes/app.css
    from /home/hakim/.gem/ruby/2.4.0/gems/sass-3.4.23/lib/sass/exec/sass_scss.rb:51:in `process_result'
    from /home/hakim/.gem/ruby/2.4.0/gems/sass-3.4.23/lib/sass/exec/base.rb:52:in `parse'
    from /home/hakim/.gem/ruby/2.4.0/gems/sass-3.4.23/lib/sass/exec/base.rb:19:in `parse!'
    from /home/hakim/.gem/ruby/2.4.0/gems/sass-3.4.23/bin/sass:13:in `<top (required)>'
    from /home/hakim/.gem/ruby/2.4.0/bin/sass:22:in `load'
    from /home/hakim/.gem/ruby/2.4.0/bin/sass:22:in `<main>'

静态文件存储在os.path.join(BASE_DIR, 'static')

这是我setting.py的相关部分:

# Manage static files with pipeline 
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage' 

# Where to generate CSS from SCSS
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

# Specify SCSS files to be compiled to CSS
PIPELINE = {
    'STYLESHEETS': {
        'librairies': {
            'source_filenames': (
                 'quotes/app.scss',
             ),
             'output_filename': 'quotes/app.css',
         },
     },
     'COMPILERS': (
         'pipeline.compilers.sass.SASSCompiler',
     ),
     'SASS_ARGUMENTS': "--trace --update -I '%s'" % os.path.join(
         BOWER_COMPONENTS_ROOT,
         'bower_components',
         'foundation',
         'scss'
    ),
}

app.scss仅包含app.scss @import 'foundation';

我设法解决了以上问题,该问题是由于我忘记考虑app.scss的文件夹层次结构(导入基础时)引起的。 通过将此文件与下载的foundation-sites一起放在/static ,并按如下所示设置其内容,我设法使其工作:

@import 'foundation-sites/scss/settings/_settings.scss';
@import 'foundation-sites/scss/foundation.scss';

@include foundation-everything;