diff --git a/mkdocs/livereload/__init__.py b/mkdocs/livereload/__init__.py index 58066e95..f551a794 100644 --- a/mkdocs/livereload/__init__.py +++ b/mkdocs/livereload/__init__.py @@ -311,7 +311,7 @@ class LiveReloadServer(socketserver.ThreadingMixIn, wsgiref.simple_server.WSGISe def _guess_type(cls, path): # MkDocs only ensures a few common types (as seen in livereload_tests.py::test_mime_types). # Other uncommon types will not be accepted. - if path.endswith((".js", ".JS")): + if path.endswith((".js", ".JS", ".mjs")): return "application/javascript" if path.endswith(".gz"): return "application/gzip" diff --git a/mkdocs/structure/files.py b/mkdocs/structure/files.py index 5d148c4c..76f6d475 100644 --- a/mkdocs/structure/files.py +++ b/mkdocs/structure/files.py @@ -269,7 +269,7 @@ class File: def is_javascript(self) -> bool: """Return True if file is a JavaScript file.""" - return self.src_uri.endswith(('.js', '.javascript')) + return self.src_uri.endswith(('.js', '.javascript', '.mjs')) def is_css(self) -> bool: """Return True if file is a CSS file."""