Django压缩机与基础SCS 我试图用Django压缩器的预编译器将基础SCS集成到Django中,这个项目看起来是这样的: ├── manage.py ├── requirements.txt ├── static │ ├── config.rb │ ├── humans.txt │ ├── index.html │ ├── javascripts │ │ ├── foundation │ │ │ ├── foundation.alerts.js │ │ │ ├── foundation.clearing.js │ │ │ ├── foundation.cookie.js │ │ │ ├── foundation.dropdown.js │ │ │ ├── foundation.forms.js │ │ │ ├── foundation.joyride.js │ │ │ ├── foundation.js │ │ │ ├── foundation.magellan.js │ │ │ ├── foundation.orbit.js │ │ │ ├── foundation.placeholder.js │ │ │ ├── foundation.reveal.js │ │ │ ├── foundation.section.js │ │ │ ├── foundation.tooltips.js │ │ │ └── foundation.topbar.js │ │ └── vendor │ │ ├── custom.modernizr.js │ │ ├── jquery.js │ │ └── zepto.js │ ├── MIT-LICENSE.txt │ ├── robots.txt │ ├── sass │ │ ├── app.scss │ │ ├── normalize.scss │ │ └── _settings.scss │ └── stylesheets │ ├── app.css │ └── normalize.css ├── templates │ ├── 404.html │ ├── 500.html │ ├── admin │ │ └── base_site.html │ └── base.html └── weddings ├── __init__.py ├── __init__.pyc ├── local_settings.py ├── local_settings.pyc ├── settings.py ├── settings.pyc ├── urls.py ├── urls.pyc └── wsgi.py
而预编译器在settings.py中是这样的Django压缩机与基础SCS 我试图用Django压缩器的预编译器将基础SCS集成到Django中,这个项目看起来是这样的: ├── manage.py ├── requirements.txt ├── static │ ├── config.rb │ ├── humans.txt │ ├── index.html │ ├── javascripts │ │ ├── foundation │ │ │ ├── foundation.alerts.js │ │ │ ├── foundation.clearing.js │ │ │ ├── foundation.cookie.js │ │ │ ├── foundation.dropdown.js │ │ │ ├── foundation.forms.js │ │ │ ├── foundation.joyride.js │ │ │ ├── foundation.js │ │ │ ├── foundation.magellan.js │ │ │ ├── foundation.orbit.js │ │ │ ├── foundation.placeholder.js │ │ │ ├── foundation.reveal.js │ │ │ ├── foundation.section.js │ │ │ ├── foundation.tooltips.js │ │ │ └── foundation.topbar.js │ │ └── vendor │ │ ├── custom.modernizr.js │ │ ├── jquery.js │ │ └── zepto.js │ ├── MIT-LICENSE.txt │ ├── robots.txt │ ├── sass │ │ ├── app.scss │ │ ├── normalize.scss │ │ └── _settings.scss │ └── stylesheets │ ├── app.css │ └── normalize.css ├── templates │ ├── 404.html │ ├── 500.html │ ├── admin │ │ └── base_site.html │ └── base.html └── weddings ├── __init__.py ├── __init__.pyc ├── local_settings.py ├── local_settings.pyc ├── settings.py ├── settings.pyc ├── urls.py ├── urls.pyc └── wsgi.py,django,sass,zurb-foundation,Django,Sass,Zurb Foundation,而预编译器在settings.py中是这样的 COMPRESS_PRECOMPILERS = ( ('text/x-scss', 'sass --scss --compass {infile} {outfile}'), ) 当我使用nginx+uwsgi运行它时,我得到以下错误: Syntax error: File to import not found or unreadable: foundation/foundation-global. Load p
COMPRESS_PRECOMPILERS = (
('text/x-scss', 'sass --scss --compass {infile} {outfile}'),
)
当我使用nginx+uwsgi运行它时,我得到以下错误:
Syntax error: File to import not found or unreadable: foundation/foundation-global.
Load paths:
/etc/uwsgi/vassals
/etc/uwsgi/vassals/sass
/srv/www/weddings/gems/compass-0.12.2/frameworks/blueprint/stylesheets
/srv/www/weddings/gems/compass-0.12.2/frameworks/compass/stylesheets
Compass::SpriteImporter
/srv/www/weddings/gems/bourbon-3.1.1/app/assets/stylesheets
/srv/www/weddings/gems/bourbon-3.1.1/app/assets/stylesheets
on line 2 of /srv/www/weddings/weddings/static/sass/_settings.scss
from line 2 of /srv/www/weddings/weddings/static/sass/app.scss
Use --trace for backtrace.
我怀疑它没有读取config.rb,或者config.rb中的设置有误:
http_path = "/"
css_dir = "stylesheets"
sass_dir = "sass"
images_dir = "images"
javascripts_dir = "javascripts"
我目前的工作是在ocnfig.rb所在的文件夹中运行sass命令
COMPRESS_PRECOMPILERS = (
('text/x-scss', 'cd /srv/www/project/name/static && sass --scss --compass {infile} {outfile}'),
)
因为您有一个
config.rb
文件,所以您有一个Compass项目
Compass项目应该使用Compass
命令行工具而不是sass
命令行工具来编译
正如您已经发现的,编译应该从insie项目文件夹启动。但是将路径硬编码到settings.py中是一个坏主意,因为它会使您的项目变得不可移植
您应该使用os.path.dirname(os.path.realpath(_文件__))来发现当前脚本的路径,而不是硬编码的路径。要更改相对于settings.py
的文件夹,请像这样使用os.path.join()
(根据需要进行调整,您可以使用。
):
此外,您的设置.py
中可能已经有PROJECT\u DIR
var。使用它使这条线更干净。对@James Lin有一点改进
COMPRESS_PRECOMPILERS = (
# ('text/x-scss', 'django_libsass.SassCompiler'),
# ('text/x-scss', 'sass --scss {infile} {outfile}'),
('text/x-scss', 'sass --scss --compass {infile} {outfile}'),
)
谢谢,这澄清了一点,关于你对硬编码路径的建议,我实际上使用了你推荐的('text/x-scss',cd{0}/static&&sass--scss--compass--require bourbon.rb{infle}{outfile}}格式(PROJECT_ROOT)),
我认为在这里显示实际路径会更容易阅读。
COMPRESS_PRECOMPILERS = (
# ('text/x-scss', 'django_libsass.SassCompiler'),
# ('text/x-scss', 'sass --scss {infile} {outfile}'),
('text/x-scss', 'sass --scss --compass {infile} {outfile}'),
)