diff --git a/dash/dash.py b/dash/dash.py index c0a4a9c..c8a2357 100644 --- a/dash/dash.py +++ b/dash/dash.py @@ -74,7 +74,8 @@ def __init__(self, data, encoder=plotly.utils.PlotlyJSONEncoder, safe=False, _re_index_scripts_id = re.compile(r'src=".*dash[-_]renderer.*"') -# pylint: disable=too-many-instance-attributes, too-many-arguments, too-many-locals +# pylint: disable=too-many-instance-attributes +# pylint: disable=too-many-arguments, too-many-locals class Dash(object): # pylint: disable=unused-argument def __init__(self, url_base_pathname='/', @@ -249,11 +250,17 @@ def _relative_url_path(path_prefix, relative_package_path='', namespace=''): srcs = [] for resource in resources: + is_dynamic_resource = resource.get('dynamic', False) + if 'relative_package_path' in resource: - if isinstance(resource['relative_package_path'], str): - srcs.append(_relative_url_path(path_prefix, **resource)) - else: - for rel_path in resource['relative_package_path']: + paths = resource['relative_package_path'] + paths = [paths] if isinstance(paths, str) else paths + + for rel_path in paths: + self.registered_paths[resource['namespace']]\ + .add(rel_path) + + if not is_dynamic_resource: srcs.append(_relative_url_path( path_prefix, relative_package_path=rel_path, diff --git a/dash/resources.py b/dash/resources.py index 43caf44..8f5cfbc 100644 --- a/dash/resources.py +++ b/dash/resources.py @@ -18,6 +18,8 @@ def _filter_resources(self, all_resources, dev_bundles=False): filtered_resources = [] for s in all_resources: filtered_resource = {} + if 'dynamic' in s: + filtered_resource['dynamic'] = s['dynamic'] if 'namespace' in s: filtered_resource['namespace'] = s['namespace'] if 'external_url' in s and not self.config.serve_locally: diff --git a/dash/views.py b/dash/views.py index 30eaf47..05da77a 100644 --- a/dash/views.py +++ b/dash/views.py @@ -118,7 +118,8 @@ def _dash_component_suites(self, request, *args, **kwargs): # pylint: disable=u ext = kwargs.get('path_in_package_dist', '').split('.')[-1] mimetype = { 'js': 'application/JavaScript', - 'css': 'text/css' + 'css': 'text/css', + 'map': 'application/json', }[ext] response = HttpResponse(self.dash.serve_component_suites(*args, **kwargs), content_type=mimetype) diff --git a/dev-requirements.txt b/dev-requirements.txt index 27c5fa1..bfd52dc 100644 --- a/dev-requirements.txt +++ b/dev-requirements.txt @@ -1,4 +1,4 @@ -;dash_core_components==0.35.1 +;dash_core_components>=0.40.2 ;dash_html_components>=0.14.0rc4 ;dash_renderer>=0.14.1 ;Django>=1.9,<2.2 diff --git a/requirements.txt b/requirements.txt index 0f37e91..c9a0d73 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -;dash_core_components==0.35.1 +;dash_core_components>=0.40.2 ;dash_html_components>=0.14.0rc4 plotly>=2.0.8 dash-renderer>=0.14.1 diff --git a/tox.ini b/tox.ini index e7fdd35..731d1f5 100644 --- a/tox.ini +++ b/tox.ini @@ -22,7 +22,7 @@ passenv = * [py__] commands = - pip install "dash_core_components==0.35.1" --no-deps + pip install "dash_core_components>=0.40.2" --no-deps pip install "dash_html_components>=0.14.0rc4" --no-deps python --version python -m unittest tests.development.test_base_component @@ -34,7 +34,7 @@ commands = [py__dj] changedir=tests/django_project commands = - pip install "dash_core_components==0.35.1" --no-deps + pip install "dash_core_components>=0.40.2" --no-deps pip install "dash_html_components>=0.14.0rc4" --no-deps python --version python manage.py collectstatic --noinput