4
我試圖設置Django Compressor與亞馬遜S3和SASS,但我遇到了這個問題。Django Compressor,S3和SASS,編譯的文件沒有上傳
所以,這些都是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
我做錯了什麼?
CachedS3BotoStorage是做什麼的?這是如何解決它的? – Alper
我不記得我在哪裏獲得CachedS3BotoStorage,但我認爲它來自這裏http://jeanphix.me/2012/02/08/django-heroku-compressor-storages/ :) – patrick