Browse Source

add e configura django-webpack-loader

pull/2485/head
Leandro Roberto 7 years ago
parent
commit
de1eabafde
  1. 1
      requirements/requirements.txt
  2. 13
      sapl/settings.py
  3. 10
      sapl/templates/base.html
  4. 1
      setup.py

1
requirements/requirements.txt

@ -13,6 +13,7 @@ django-reversion-compare==0.8.6
django-speedinfo==1.4.0 django-speedinfo==1.4.0
django-extensions==2.1.4 django-extensions==2.1.4
django-image-cropping==1.2 django-image-cropping==1.2
django-webpack-loader==0.6.0
easy-thumbnails==2.5 easy-thumbnails==2.5
python-decouple==3.1 python-decouple==3.1
psycopg2-binary==2.7.6.1 psycopg2-binary==2.7.6.1

13
sapl/settings.py

@ -27,6 +27,8 @@ host = socket.gethostbyname_ex(socket.gethostname())[0]
BASE_DIR = Path(__file__).ancestor(1) BASE_DIR = Path(__file__).ancestor(1)
PROJECT_DIR = Path(__file__).ancestor(2) PROJECT_DIR = Path(__file__).ancestor(2)
FRONTEND_DIR = PROJECT_DIR.child('sapl-frontend')
# SECURITY WARNING: keep the secret key used in production secret! # SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = config('SECRET_KEY', default='') SECRET_KEY = config('SECRET_KEY', default='')
@ -93,6 +95,8 @@ INSTALLED_APPS = (
'whoosh', 'whoosh',
'speedinfo', 'speedinfo',
'webpack_loader',
) + SAPL_APPS ) + SAPL_APPS
# FTS = Full Text Search # FTS = Full Text Search
@ -259,6 +263,15 @@ LOCALE_PATHS = (
'locale', 'locale',
) )
WEBPACK_LOADER = {
'DEFAULT': {
'CACHE': not DEBUG,
'BUNDLE_DIR_NAME': 'bundle/dist/',
'STATS_FILE': FRONTEND_DIR.child('webpack-stats.json'),
}
}
# Static files (CSS, JavaScript, Images) # Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/ # https://docs.djangoproject.com/en/1.8/howto/static-files/

10
sapl/templates/base.html

@ -1,6 +1,8 @@
<!DOCTYPE html> <!DOCTYPE html>
{% load i18n staticfiles menus %} {% load i18n staticfiles menus %}
{% load common_tags %} {% load common_tags %}
{% load render_bundle from webpack_loader %}
<!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]--> <!--[if IE 8]> <html class="no-js lt-ie9" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <!--[if gt IE 8]><!-->
<html class="no-js" lang="pt-br"> <html class="no-js" lang="pt-br">
@ -27,6 +29,8 @@
{# Scripts #} {# Scripts #}
{# modernizr must be in head (see http://modernizr.com/docs/#installing) #} {# modernizr must be in head (see http://modernizr.com/docs/#installing) #}
{% endcomment %} {% endcomment %}
{% render_bundle 'app' 'css' %}
{% endblock %} {% endblock %}
</head> </head>
@ -163,7 +167,9 @@
{% endblock base_header %} {% endblock base_header %}
{# Content per se #} {# Content per se #}
{% block base_content %}{% endblock %} {% block base_content %}
<div id="app"></div>
{% endblock %}
</div> </div>
</main> </main>
@ -231,6 +237,8 @@
{% endif %} {% endif %}
{% block foot_js %} {% block foot_js %}
{% render_bundle 'app' 'js' %}
{% comment "" %} {% comment "" %}
<!-- Bootstrap core JavaScript ================================================== --> <!-- Bootstrap core JavaScript ================================================== -->

1
setup.py

@ -24,6 +24,7 @@ install_requires = [
'django-speedinfo==1.4.0', 'django-speedinfo==1.4.0',
'django-extensions==2.1.4', 'django-extensions==2.1.4',
'django-image-cropping==1.2.0', 'django-image-cropping==1.2.0',
'django-webpack-loader==0.6.0',
'easy-thumbnails==2.5', 'easy-thumbnails==2.5',
'python-decouple==3.1', 'python-decouple==3.1',
'psycopg2-binary==2.7.6.1', 'psycopg2-binary==2.7.6.1',

Loading…
Cancel
Save