use Webpack code-splitting to dynamically import Highlight.js languages as they are detected by Showdown Markdown extension

This commit is contained in:
Alec Merdler 2017-08-01 13:28:24 -04:00
parent 8dc2a99926
commit 41c12c853c
9 changed files with 70 additions and 33 deletions

View file

@ -56,10 +56,10 @@ def common_login(user_uuid, permanent_session=True):
return False
def _list_files(path, extension):
def _list_files(path, extension, contains=""):
""" Returns a list of all the files with the given extension found under the given path. """
def matches(f):
return os.path.splitext(f)[1] == '.' + extension and f.split(os.path.extsep)[1] != 'spec'
return os.path.splitext(f)[1] == '.' + extension and contains in os.path.splitext(f)[0]
def join_path(dp, f):
# Remove the static/ prefix. It is added in the template.
@ -74,7 +74,7 @@ def render_page_template(name, route_data=None, **kwargs):
library_styles = []
main_styles = []
library_scripts = []
main_scripts = _list_files('build', 'js')
main_scripts = _list_files('build', 'js', "bundle")
use_cdn = app.config.get('USE_CDN', True)
if request.args.get('use_cdn') is not None: