From de1eabafde78e981eed860c0e1f971d7c284c5ae Mon Sep 17 00:00:00 2001 From: Leandro Roberto Date: Sun, 13 Jan 2019 01:01:41 -0200 Subject: [PATCH] add e configura django-webpack-loader --- requirements/requirements.txt | 1 + sapl/settings.py | 13 +++++++++++++ sapl/templates/base.html | 10 +++++++++- setup.py | 1 + 4 files changed, 24 insertions(+), 1 deletion(-) diff --git a/requirements/requirements.txt b/requirements/requirements.txt index 86c03de38..15ea25054 100644 --- a/requirements/requirements.txt +++ b/requirements/requirements.txt @@ -13,6 +13,7 @@ django-reversion-compare==0.8.6 django-speedinfo==1.4.0 django-extensions==2.1.4 django-image-cropping==1.2 +django-webpack-loader==0.6.0 easy-thumbnails==2.5 python-decouple==3.1 psycopg2-binary==2.7.6.1 diff --git a/sapl/settings.py b/sapl/settings.py index b522eb99b..cf609f6ea 100755 --- a/sapl/settings.py +++ b/sapl/settings.py @@ -27,6 +27,8 @@ host = socket.gethostbyname_ex(socket.gethostname())[0] BASE_DIR = Path(__file__).ancestor(1) PROJECT_DIR = Path(__file__).ancestor(2) +FRONTEND_DIR = PROJECT_DIR.child('sapl-frontend') + # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = config('SECRET_KEY', default='') @@ -93,6 +95,8 @@ INSTALLED_APPS = ( 'whoosh', 'speedinfo', + 'webpack_loader', + ) + SAPL_APPS # FTS = Full Text Search @@ -259,6 +263,15 @@ LOCALE_PATHS = ( '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) # https://docs.djangoproject.com/en/1.8/howto/static-files/ diff --git a/sapl/templates/base.html b/sapl/templates/base.html index 79cbd4a86..dc0a499a5 100644 --- a/sapl/templates/base.html +++ b/sapl/templates/base.html @@ -1,6 +1,8 @@ {% load i18n staticfiles menus %} {% load common_tags %} +{% load render_bundle from webpack_loader %} + @@ -27,6 +29,8 @@ {# Scripts #} {# modernizr must be in head (see http://modernizr.com/docs/#installing) #} {% endcomment %} + {% render_bundle 'app' 'css' %} + {% endblock %} @@ -163,7 +167,9 @@ {% endblock base_header %} {# Content per se #} - {% block base_content %}{% endblock %} + {% block base_content %} +
+ {% endblock %} @@ -231,6 +237,8 @@ {% endif %} {% block foot_js %} + {% render_bundle 'app' 'js' %} + {% comment "" %} diff --git a/setup.py b/setup.py index a55e628b0..827026c79 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,7 @@ install_requires = [ 'django-speedinfo==1.4.0', 'django-extensions==2.1.4', 'django-image-cropping==1.2.0', + 'django-webpack-loader==0.6.0', 'easy-thumbnails==2.5', 'python-decouple==3.1', 'psycopg2-binary==2.7.6.1',