Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 481 - Support arbitrary file extensions in component suites #1078

Merged
merged 26 commits into from
Apr 24, 2020
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ This project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

### Added
- [#1078](https://github.com/plotly/dash/pull/1078) Add support for arbitrary file extensions in component packages

### Changed
- [#1035](https://github.com/plotly/dash/pull/1035) Simplify our build process.
- [#1074](https://github.com/plotly/dash/pull/1045) Error messages when providing an incorrect property to a component have been improved: they now specify the component type, library, version, and ID (if available).
- [#1074](https://github.com/plotly/dash/pull/1074) Error messages when providing an incorrect property to a component have been improved: they now specify the component type, library, version, and ID (if available).

### Fixed
- [#1037](https://github.com/plotly/dash/pull/1037) Fix no_update test to allow copies, such as those stored and retrieved from a cache.
Expand Down
15 changes: 8 additions & 7 deletions dash/dash.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import re
import logging
import pprint
import mimetypes

from functools import wraps
from textwrap import dedent
Expand Down Expand Up @@ -39,6 +40,9 @@
from ._configs import get_combined_config, pathname_configs
from .version import __version__

# Add explicit mapping for map files
mimetypes.add_type('application/json', '.map', True)

_default_index = """<!DOCTYPE html>
<html>
<head>
Expand Down Expand Up @@ -703,13 +707,10 @@ def serve_component_suites(self, package_name, path_in_package_dist):
)
)

mimetype = (
{
"js": "application/javascript",
"css": "text/css",
"map": "application/json",
}
)[path_in_package_dist.split(".")[-1]]
resource_path = os.path.dirname(sys.modules[package_name].__file__)
full_path = os.path.join(resource_path, path_in_package_dist)

(mimetype, _) = mimetypes.guess_type(full_path)

package = sys.modules[package_name]
self.logger.debug(
Expand Down