2016년 11월 24일 목요일

Django에서 Babel 설정 | Babel with Django

pip and npm packages

$ pip install django_compressor
$ npm install -g babel-cli

[project]/settings.py

...
INSTALLED_APPS = (
    ...
    'compressor',
    ...
)
...
STATICFILES_FINDERS = (
    ...
    'django.contrib.staticfiles.finders.FileSystemFinder',
    'django.contrib.staticfiles.finders.AppDirectoriesFinder',
    'compressor.finders.CompressorFinder',
    ...
)
...
COMPRESS_PRECOMPILERS = (
    ('text/es6+javascript', 'babel -o {outfile} {infile}'),
)

How to use in templates

{% load compress %}
...
{% compress js %}
<script src='{% static "es/main.es" %}' type='text/es6+javascript'></script>
{% endcompress %}
...

Read More

댓글 없음:

댓글 쓰기