1
Amazon S3에 저장되어있는 js 및 css를 manage.py compress 명령을 사용하여 미리 압축하려면 django-compress를 사용하고 있습니다.django-compress는 절대 URL로 CSS의 상대 URL을 대체하지 않음
그러나 문제는 내 CSS 내의 상대적인 img URL이 절대 URL로 대체되지 않는다는 것입니다.
그래서 내가 제대로 압축 명령을 실행 한 후 이미지의 절대 S3의 URL로 대체되지 않는background-image:url("../img/image1.png")
같은 CSS의 이미지 URL이 있습니다. 대신
https://webappbucket.s3.amazon.com/img/image1.png
같은 것을가되는이 압축 된 CSS에서
로"../img/image1.png"
유지됩니다.
STATICFILES_DIRS = (
'webapp/static',
)
INSTALLED_APPS += ('storages',)
STATICFILES_STORAGE = 'lib.storage.CachedS3BotoStorage'
AWS_ACCESS_KEY_ID = constants.AWS_ACCESS_KEY_ID
AWS_SECRET_ACCESS_KEY = constants.AWS_SECRET_ACCESS_KEY
AWS_STORAGE_BUCKET_NAME = constants.S3_BUCKET_NAME
S3_URL = 'https://%s.s3.amazonaws.com/' % AWS_STORAGE_BUCKET_NAME
STATIC_URL = S3_URL
#compress
COMPRESS = True
COMPRESS_OFFLINE = True
COMPRESS_ROOT = "../"
COMPRESS_ENABLED = True
COMPRESS_STORAGE = STATICFILES_STORAGE
COMPRESS_JS_FILTERS = [
'lib.compressor_filters.YUglifyJSFilter',
]
COMPRESS_CSS_FILTERS = [
'lib.compressor_filters.YUglifyCSSFilter',
]
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# other finders..
'compressor.finders.CompressorFinder',
)
COMPRESS_YUGLIFY_BINARY = 'node_modules/yuglify/bin/yuglify' # assumes yuglify is in your path
COMPRESS_YUGLIFY_CSS_ARGUMENTS = '--terminal'
COMPRESS_YUGLIFY_JS_ARGUMENTS = '--terminal'
COMPRESS_URL = STATIC_URL
STATIC_ROOT = "../"
AWS_QUERYSTRING_AUTH = False