Skip to content
Snippets Groups Projects
Commit 250502ff authored by Vikas's avatar Vikas
Browse files

Allow running project without webpack/node

Add a new `render_bundle` template tag which conditionally renders
webpack-loader bundles based on ENABLE_WEBPACK_BUNDLES setting.

When disabled, it makes the React/Webpack loaded parts disapper.
parent a06c1d20
No related branches found
No related tags found
No related merge requests found
{% extends "base-apply.html" %}
{% load static %}
{% load render_bundle from webpack_loader %}
{% load render_bundle from webpack_tags %}
{% block extra_css %}
<link rel="stylesheet" href="{% static 'css/apply/fancybox.css' %}">
......@@ -36,6 +36,3 @@
<script src="{% static 'js/apply/batch-actions.js' %}"></script>
<script src="{% static 'js/apply/flag.js' %}"></script>
{% endblock %}
{% load render_bundle from webpack_loader %}
{% extends "funds/base_submissions_table.html" %}
{% load static %}
{% load render_bundle from webpack_loader %}
{% load render_bundle from webpack_tags %}
{% block title %}Submissions{% endblock %}
{% block content %}
......
{% extends "funds/base_submissions_table.html" %}
{% load static %}
{% load render_bundle from webpack_loader %}
{% load render_bundle from webpack_tags %}
{% block title %}{{ object }}{% endblock %}
......
{% extends "funds/base_submissions_table.html" %}
{% load render_bundle from webpack_loader %}
{% load render_bundle from webpack_tags %}
{% block title %}{{ status }}{% endblock %}
......
from django import template
from django.conf import settings
from webpack_loader.templatetags import webpack_loader
register = template.Library()
@register.simple_tag
def render_bundle(bundle_name, extension=None, config='DEFAULT', attrs=''):
"""
Render webpack bundle if enabled in settings.
Passes the options to actual `render_bundle` template tag provided by `webpack_loader`.
Use this instead of `webpack_loader`.
"""
if settings.ENABLE_WEBPACK_BUNDLES:
return webpack_loader.render_bundle(bundle_name, extension, config, attrs)
return ''
......@@ -139,7 +139,6 @@ INSTALLED_APPS = [
'hijack',
'compat',
'pagedown',
'webpack_loader',
'salesforce',
......@@ -659,6 +658,9 @@ if env.get('COOKIE_SECURE', 'false').lower().strip() == 'true':
REFERRER_POLICY = env.get('SECURE_REFERRER_POLICY',
'no-referrer-when-downgrade').strip()
# Webpack bundle loader
# When disabled, all included bundles are silently ignored.
ENABLE_WEBPACK_BUNDLES = True
WEBPACK_LOADER = {
'DEFAULT': {
'BUNDLE_DIR_NAME': 'app/',
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment