我正在尝试使用 Amazon s3 和 SASS 设置 Django Compressor,但我遇到了这个问题。
因此,这些是 django 压缩器的设置:
########## STATIC FILE CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-root
STATIC_ROOT = normpath(join(SITE_ROOT, 'static'))
# See: https://docs.djangoproject.com/en/dev/ref/settings/#static-url
STATIC_URL = '/static/'
# See: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#std:setting-STATICFILES_DIRS
STATICFILES_DIRS = (
normpath(join(SITE_ROOT, 'assets')),
)
COMPRESS_CSS_FILTERS = [
#creates absolute urls from relative ones
'compressor.filters.css_default.CssAbsoluteFilter',
#css minimizer
'compressor.filters.cssmin.CSSMinFilter'
]
COMPRESS_OUTPUT_DIR = '' #fixes bug with absolute urls
COMPRESS_PRECOMPILERS = (
('text/x-scss', 'sass --scss --compass {infile} {outfile}'),
('text/x-sass', 'sass --compass {infile} {outfile}'),
)
DEFAULT_FILE_STORAGE = 'devfest.storage.CachedS3BotoStorage'
STATICFILES_STORAGE = DEFAULT_FILE_STORAGE
AWS_ACCESS_KEY_ID = get_env_setting('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = get_env_setting('AWS_SECRET_ACCESS_KEY')
AWS_STORAGE_BUCKET_NAME = 'asd'
COMPRESS_OFFLINE = True
COMPRESS_ENABLED = True
COMPRESS_URL = 'https://{}.s3.amazonaws.com/'.format(AWS_STORAGE_BUCKET_NAME)
COMPRESS_ROOT = STATIC_ROOT
这是调用文件的模板部分
{% compress css %}
<link rel="stylesheet" href="{% static 'css/normalize.css' %}">
<link rel="stylesheet" type="text/x-sass" href="{% static 'css/main.sass' %}">
<link rel="stylesheet" href="{% static 'css/font-awesome.min.css' %}">
{% endcompress css %}
问题是压缩文件没有上传,因为它们被放在一个专用文件夹中(仅上传资产中的文件)
» tree static/
static/
├── css
│ └── 46086ae5ebb4.css
└── manifest.json
我做错什么了吗?