From df3ed76f3e92f9ea15b79da7e0e6c78d24c21d3c Mon Sep 17 00:00:00 2001 From: David Larlet Date: Fri, 19 Jan 2024 09:22:09 -0500 Subject: [PATCH] feat: generate/link source map files for JS and CSS --- umap/utils.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/umap/utils.py b/umap/utils.py index 27f973ca..e61a882f 100644 --- a/umap/utils.py +++ b/umap/utils.py @@ -222,10 +222,18 @@ class UmapManifestStaticFilesStorage(ManifestStaticFilesStorage): for original_path, processed_path, processed in collected: if processed_path.endswith(".js"): path = Path(settings.STATIC_ROOT) / processed_path - minified = jsmin(path.read_text()) + initial = path.read_text() + path_map = path.with_suffix(f"{path.suffix}.map") + minified = jsmin(initial) + minified += f"\n//# sourceMappingURL={path_map.name}" path.write_text(minified) + path_map.write_text(initial) if processed_path.endswith(".css"): path = Path(settings.STATIC_ROOT) / processed_path - minified = cssmin(path.read_text()) + initial = path.read_text() + path_map = path.with_suffix(f"{path.suffix}.map") + minified = cssmin(initial) + minified += f"\n//# sourceMappingURL={path_map.name}" path.write_text(minified) + path_map.write_text(initial) yield original_path, processed_path, True