使用 Django 管道从 Foundation 站点的 SCSS 文件构建 CSS 时出现运行时错误
RuntimeError when building CSS from SCSS files of Foundation-sites with Django-pipeline
我的问题与 Django-Bower + Foundation 5 + SASS 的背景相同。我正在尝试将 foundation
从 scss
编译为 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
仅包含 @import 'foundation';
.
我设法解决了上述问题,这是因为我忘记考虑 app.scss
中的文件夹层次结构(导入基础时)。通过将此文件与下载的 foundation-sites
一起放入 /static
并如下设置其内容,我设法使其工作:
@import 'foundation-sites/scss/settings/_settings.scss';
@import 'foundation-sites/scss/foundation.scss';
@include foundation-everything;
我的问题与 Django-Bower + Foundation 5 + SASS 的背景相同。我正在尝试将 foundation
从 scss
编译为 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
仅包含 @import 'foundation';
.
我设法解决了上述问题,这是因为我忘记考虑 app.scss
中的文件夹层次结构(导入基础时)。通过将此文件与下载的 foundation-sites
一起放入 /static
并如下设置其内容,我设法使其工作:
@import 'foundation-sites/scss/settings/_settings.scss';
@import 'foundation-sites/scss/foundation.scss';
@include foundation-everything;