对于我来说,Django static precompiler似乎不能处理scss文件。我已经检查过是否安装了编译器,django的设置如下
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'static_precompiler',
'cms',
]
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'static_precompiler.finders.StaticPrecompilerFinder',
)
STATIC_URL = '/static/'
STATIC_ROOT = "static"我在django模板中调用相同的代码,如下所示
{% load compile_static %}
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Spacemailer</title>
{% block seo %}
{% endblock %}
<link rel="stylesheet" href="{% static 'style/main.scss' | compile %}" type="text/css" media="all" />
</head>
<body>
{% block body %}
{% endblock %}
</body>
</html>没有任何错误。输出是相同的scss文件,没有进行任何编译。有人能指出我用同样的东西做错了什么吗?或者一些支持编译scss和coffee脚本的替代方案
发布于 2017-10-10 01:49:07
默认情况下,编译应该在运行时通过compile过滤器为模板提供服务。
{% static "js/alert.es6"|compile %}渲染
<script type="application/javascript" src="/static/COMPILED/js/alert.js"></script>如果您使用不同存储,且STATIC_PRECOMPILER_DISABLE_AUTO_COMPILE是True,请先使用compilestatic编译,然后再使用collectstatic编译
STATIC_PRECOMPILER_COMPILERS = (
('static_precompiler.compilers.SCSS', {
"executable": "/usr/bin/sass",
"sourcemap_enabled": True,
"compass_enabled": True,
"load_paths": ["/path"],
"precision": 8,
"output_style": "compressed",
}),
)https://stackoverflow.com/questions/45647427
复制相似问题