Merge pull request #1549 from umap-project/vendors-minified-sourcemaps

Use minified versions + sourcemaps of vendor statics
This commit is contained in:
David Larlet 2024-01-21 15:09:38 -05:00 committed by GitHub
commit 7729035288
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 62 additions and 71 deletions

View file

@ -1,33 +1,32 @@
#!/usr/bin/env sh
mkdir -p umap/static/umap/vendors/leaflet/ && cp -r node_modules/leaflet/dist/** umap/static/umap/vendors/leaflet/
mkdir -p umap/static/umap/vendors/editable/ && cp -r node_modules/leaflet-editable/src/*.js umap/static/umap/vendors/editable/
mkdir -p umap/static/umap/vendors/editable/ && cp -r node_modules/leaflet.path.drag/src/*.js umap/static/umap/vendors/editable/
mkdir -p umap/static/umap/vendors/hash/ && cp -r node_modules/leaflet-hash/*.js umap/static/umap/vendors/hash/
mkdir -p umap/static/umap/vendors/i18n/ && cp -r node_modules/leaflet-i18n/*.js umap/static/umap/vendors/i18n/
mkdir -p umap/static/umap/vendors/editable/ && cp -r node_modules/leaflet-editable/src/Leaflet.Editable.js umap/static/umap/vendors/editable/
mkdir -p umap/static/umap/vendors/editable/ && cp -r node_modules/leaflet.path.drag/src/Path.Drag.js umap/static/umap/vendors/editable/
mkdir -p umap/static/umap/vendors/hash/ && cp -r node_modules/leaflet-hash/leaflet-hash.js umap/static/umap/vendors/hash/
mkdir -p umap/static/umap/vendors/i18n/ && cp -r node_modules/leaflet-i18n/Leaflet.i18n.js umap/static/umap/vendors/i18n/
mkdir -p umap/static/umap/vendors/editinosm/ && cp -r node_modules/leaflet-editinosm/Leaflet.EditInOSM.* umap/static/umap/vendors/editinosm/
mkdir -p umap/static/umap/vendors/editinosm/ && cp -r node_modules/leaflet-editinosm/edit-in-osm.png umap/static/umap/vendors/editinosm/
mkdir -p umap/static/umap/vendors/minimap/ && cp -r node_modules/leaflet-minimap/src/** umap/static/umap/vendors/minimap/
mkdir -p umap/static/umap/vendors/loading/ && cp -r node_modules/leaflet-loading/src/** umap/static/umap/vendors/loading/
mkdir -p umap/static/umap/vendors/minimap/ && cp -r node_modules/leaflet-minimap/dist/** umap/static/umap/vendors/minimap/
mkdir -p umap/static/umap/vendors/loading/ && cp -r node_modules/leaflet-loading/src/Control.Loading.* umap/static/umap/vendors/loading/
mkdir -p umap/static/umap/vendors/markercluster/ && cp -r node_modules/leaflet.markercluster/dist/** umap/static/umap/vendors/markercluster/
mkdir -p umap/static/umap/vendors/contextmenu/ && cp -r node_modules/leaflet-contextmenu/dist/** umap/static/umap/vendors/contextmenu/
mkdir -p umap/static/umap/vendors/heat/ && cp -r node_modules/leaflet.heat/dist/** umap/static/umap/vendors/heat/
mkdir -p umap/static/umap/vendors/contextmenu/ && cp -r node_modules/leaflet-contextmenu/dist/leaflet.contextmenu.min.* umap/static/umap/vendors/contextmenu/
mkdir -p umap/static/umap/vendors/heat/ && cp -r node_modules/leaflet.heat/dist/leaflet-heat.js umap/static/umap/vendors/heat/
mkdir -p umap/static/umap/vendors/fullscreen/ && cp -r node_modules/leaflet-fullscreen/dist/** umap/static/umap/vendors/fullscreen/
mkdir -p umap/static/umap/vendors/toolbar/ && cp -r node_modules/leaflet-toolbar/dist/** umap/static/umap/vendors/toolbar/
mkdir -p umap/static/umap/vendors/formbuilder/ && cp -r node_modules/leaflet-formbuilder/*.js umap/static/umap/vendors/formbuilder/
mkdir -p umap/static/umap/vendors/formbuilder/ && cp -r node_modules/leaflet-formbuilder/Leaflet.FormBuilder.js umap/static/umap/vendors/formbuilder/
mkdir -p umap/static/umap/vendors/measurable/ && cp -r node_modules/leaflet-measurable/Leaflet.Measurable.* umap/static/umap/vendors/measurable/
mkdir -p umap/static/umap/vendors/photon/ && cp -r node_modules/leaflet.photon/*.js umap/static/umap/vendors/photon/
mkdir -p umap/static/umap/vendors/csv2geojson/ && cp -r node_modules/csv2geojson/*.js umap/static/umap/vendors/csv2geojson/
mkdir -p umap/static/umap/vendors/togeojson/ && cp -r node_modules/@tmcw/togeojson/dist/togeojson.umd.js umap/static/umap/vendors/togeojson/togeojson.js
mkdir -p umap/static/umap/vendors/photon/ && cp -r node_modules/leaflet.photon/leaflet.photon.js umap/static/umap/vendors/photon/
mkdir -p umap/static/umap/vendors/csv2geojson/ && cp -r node_modules/csv2geojson/csv2geojson.js umap/static/umap/vendors/csv2geojson/
mkdir -p umap/static/umap/vendors/togeojson/ && cp -r node_modules/@tmcw/togeojson/dist/togeojson.umd.* umap/static/umap/vendors/togeojson/
mkdir -p umap/static/umap/vendors/osmtogeojson/ && cp -r node_modules/osmtogeojson/osmtogeojson.js umap/static/umap/vendors/osmtogeojson/
mkdir -p umap/static/umap/vendors/georsstogeojson/ && cp -r node_modules/georsstogeojson/GeoRSSToGeoJSON.js umap/static/umap/vendors/georsstogeojson/
mkdir -p umap/static/umap/vendors/togpx/ && cp -r node_modules/togpx/togpx.js umap/static/umap/vendors/togpx/
mkdir -p umap/static/umap/vendors/tokml && cp -r node_modules/tokml/tokml.js umap/static/umap/vendors/tokml
mkdir -p umap/static/umap/vendors/locatecontrol/ && cp -r node_modules/leaflet.locatecontrol/dist/L.Control.Locate.css umap/static/umap/vendors/locatecontrol/
mkdir -p umap/static/umap/vendors/locatecontrol/ && cp -r node_modules/leaflet.locatecontrol/src/L.Control.Locate.js umap/static/umap/vendors/locatecontrol/
mkdir -p umap/static/umap/vendors/dompurify/ && cp -r node_modules/dompurify/dist/purify.js umap/static/umap/vendors/dompurify/
mkdir -p umap/static/umap/vendors/locatecontrol/ && cp -r node_modules/leaflet.locatecontrol/dist/L.Control.Locate.min.* umap/static/umap/vendors/locatecontrol/
mkdir -p umap/static/umap/vendors/dompurify/ && cp -r node_modules/dompurify/dist/purify.min.* umap/static/umap/vendors/dompurify/
mkdir -p umap/static/umap/vendors/colorbrewer/ && cp node_modules/colorbrewer/index.js umap/static/umap/vendors/colorbrewer/colorbrewer.js
mkdir -p umap/static/umap/vendors/simple-statistics/ && cp node_modules/simple-statistics/dist/simple-statistics.min.js umap/static/umap/vendors/simple-statistics/
mkdir -p umap/static/umap/vendors/simple-statistics/ && cp node_modules/simple-statistics/dist/simple-statistics.min.* umap/static/umap/vendors/simple-statistics/
mkdir -p umap/static/umap/vendors/iconlayers/ && cp node_modules/leaflet-iconlayers/dist/* umap/static/umap/vendors/iconlayers/
echo 'Done!'

View file

@ -4,31 +4,34 @@
<title>Umap front Tests</title>
<meta charset="utf-8" />
<script type="module" src="../js/modules/global.js" defer></script>
<script src="../vendors/editable/Path.Drag.js" defer></script>
<script src="../vendors/editable/Leaflet.Editable.js" defer></script>
<script src="../vendors/hash/leaflet-hash.js" defer></script>
<script src="../vendors/i18n/Leaflet.i18n.js" defer></script>
<script src="../vendors/editinosm/Leaflet.EditInOSM.js" defer></script>
<script src="../vendors/minimap/Control.MiniMap.js" defer></script>
<script src="../vendors/minimap/Control.MiniMap.min.js" defer></script>
<script src="../vendors/csv2geojson/csv2geojson.js" defer></script>
<script src="../vendors/togeojson/togeojson.js" defer></script>
<script src="../vendors/togeojson/togeojson.umd.js" defer></script>
<script src="../vendors/osmtogeojson/osmtogeojson.js" defer></script>
<script src="../vendors/contextmenu/leaflet.contextmenu.js" defer></script>
<script src="../vendors/loading/Control.Loading.js" defer></script>
<script src="../vendors/markercluster/leaflet.markercluster-src.js" defer></script>
<script src="../vendors/markercluster/leaflet.markercluster.js" defer></script>
<script src="../vendors/contextmenu/leaflet.contextmenu.min.js" defer></script>
<script src="../vendors/photon/leaflet.photon.js" defer></script>
<script src="../vendors/georsstogeojson/GeoRSSToGeoJSON.js" defer></script>
<script src="../vendors/heat/leaflet-heat.js" defer></script>
<script src="../vendors/fullscreen/Leaflet.fullscreen.js" defer></script>
<script src="../vendors/toolbar/leaflet.toolbar-src.js" defer></script>
<script src="../vendors/fullscreen/Leaflet.fullscreen.min.js" defer></script>
<script src="../vendors/toolbar/leaflet.toolbar.js" defer></script>
<script src="../vendors/formbuilder/Leaflet.FormBuilder.js" defer></script>
<script src="../vendors/measurable/Leaflet.Measurable.js" defer></script>
<script src="../vendors/locatecontrol/L.Control.Locate.js" defer></script>
<script src="../vendors/dompurify/purify.js" defer></script>
<script src="../vendors/togpx/togpx.js" defer></script>
<script src="../vendors/tokml/tokml.js" defer></script>
<script src="../vendors/iconlayers/iconLayers.js" defer></script>
<script src="../vendors/simple-statistics/simple-statistics.min.js" defer></script>
<script src="../vendors/tokml/tokml.js" defer></script>
<script src="../vendors/locatecontrol/L.Control.Locate.min.js" defer></script>
<script src="../vendors/dompurify/purify.min.js" defer></script>
<script src="../vendors/colorbrewer/colorbrewer.js" defer></script>
<script src="../vendors/simple-statistics/simple-statistics.min.js" defer></script>
<script src="../js/umap.core.js" defer></script>
<script src="../js/umap.autocomplete.js" defer></script>
<script src="../js/umap.popup.js" defer></script>
@ -36,34 +39,38 @@
<script src="../js/umap.forms.js" defer></script>
<script src="../js/umap.icon.js" defer></script>
<script src="../js/umap.features.js" defer></script>
<script src="../js/umap.permissions.js" defer></script>
<script src="../js/umap.datalayer.permissions.js" defer></script>
<script src="../js/umap.layer.js" defer></script>
<script src="../js/umap.controls.js" defer></script>
<script src="../js/umap.slideshow.js" defer></script>
<script src="../js/umap.tableeditor.js" defer></script>
<script src="../js/umap.permissions.js" defer></script>
<script src="../js/umap.datalayer.permissions.js" defer></script>
<script src="../js/umap.browser.js" defer></script>
<script src="../js/umap.importer.js" defer></script>
<script src="../js/umap.share.js" defer></script>
<script src="../js/umap.js" defer></script>
<script src="../js/umap.ui.js" defer></script>
<script src="../js/components/fragment.js" defer></script>
<link rel="stylesheet" href="../vendors/leaflet/leaflet.css" />
<link rel="stylesheet" href="../vendors/minimap/Control.MiniMap.css" />
<link rel="stylesheet" href="../vendors/editinosm/Leaflet.EditInOSM.css" />
<link rel="stylesheet" href="../vendors/markercluster/MarkerCluster.css" />
<link rel="stylesheet"
href="../vendors/markercluster/MarkerCluster.Default.css" />
<link rel="stylesheet"
href="../vendors/contextmenu/leaflet.contextmenu.css" />
<link rel="stylesheet" href="../vendors/markercluster/MarkerCluster.Default.css" />
<link rel="stylesheet" href="../vendors/editinosm/Leaflet.EditInOSM.css" />
<link rel="stylesheet" href="../vendors/minimap/Control.MiniMap.min.css" />
<link rel="stylesheet" href="../vendors/contextmenu/leaflet.contextmenu.min.css" />
<link rel="stylesheet" href="../vendors/toolbar/leaflet.toolbar.css" />
<link rel="stylesheet" href="../vendors/measurable/Leaflet.Measurable.css" />
<link rel="stylesheet" href="../vendors/fullscreen/leaflet.fullscreen.css" />
<link rel="stylesheet" href="../vendors/locatecontrol/L.Control.Locate.min.css" />
<link rel="stylesheet" href="../vendors/iconlayers/iconLayers.css" />
<link rel="stylesheet" href="../../umap/font.css" />
<link rel="stylesheet" href="../../umap/base.css" />
<link rel="stylesheet" href="../../umap/content.css" />
<link rel="stylesheet" href="../../umap/nav.css" />
<link rel="stylesheet" href="../../umap/map.css" />
<link rel="stylesheet" href="../../umap/theme.css" />
<script src="../../../../node_modules/sinon/pkg/sinon.js"></script>
<script src="../../../../node_modules/mocha/mocha.js"></script>
<script src="../../../../node_modules/chai/chai.js"></script>

View file

@ -38,34 +38,19 @@ class UmapManifestStaticFilesStorage(ManifestStaticFilesStorage):
),
)
# https://github.com/django/django/blob/0fcee1676c7f14bb08e2cc662898dee56d9cf207↩
# /django/contrib/staticfiles/storage.py#L78C5-L105C6
patterns = (
(
"*.css",
(
r"""(?P<matched>url\(['"]{0,1}\s*(?P<url>.*?)["']{0,1}\))""",
(
r"""(?P<matched>@import\s*["']\s*(?P<url>.*?)["'])""",
"""@import url("%(url)s")""",
),
# Remove CSS source map rewriting
),
),
# Remove JS source map rewriting
)
def post_process(self, paths, **options):
collected = super().post_process(paths, **options)
for original_path, processed_path, processed in collected:
if processed_path.endswith(".js"):
path = Path(settings.STATIC_ROOT) / processed_path
initial = path.read_text()
if "sourceMappingURL" not in initial: # Already minified.
minified = jsmin(initial)
path.write_text(minified)
if processed_path.endswith(".css"):
path = Path(settings.STATIC_ROOT) / processed_path
initial = path.read_text()
if "sourceMappingURL" not in initial: # Already minified.
minified = cssmin(initial)
path.write_text(minified)
yield original_path, processed_path, True

View file

@ -9,9 +9,9 @@
<link rel="stylesheet"
href="{% static 'umap/vendors/editinosm/Leaflet.EditInOSM.css' %}" />
<link rel="stylesheet"
href="{% static 'umap/vendors/minimap/Control.MiniMap.css' %}" />
href="{% static 'umap/vendors/minimap/Control.MiniMap.min.css' %}" />
<link rel="stylesheet"
href="{% static 'umap/vendors/contextmenu/leaflet.contextmenu.css' %}" />
href="{% static 'umap/vendors/contextmenu/leaflet.contextmenu.min.css' %}" />
<link rel="stylesheet"
href="{% static 'umap/vendors/toolbar/leaflet.toolbar.css' %}" />
<link rel="stylesheet"
@ -19,12 +19,12 @@
<link rel="stylesheet"
href="{% static 'umap/vendors/fullscreen/leaflet.fullscreen.css' %}" />
<link rel="stylesheet"
href="{% static 'umap/vendors/locatecontrol/L.Control.Locate.css' %}" />
href="{% static 'umap/vendors/locatecontrol/L.Control.Locate.min.css' %}" />
<link rel="stylesheet"
href="{% static 'umap/vendors/iconlayers/iconLayers.css' %}" />
<link rel="stylesheet" href="{% static 'umap/font.css' %}">
<link rel="stylesheet" href="{% static 'umap/base.css' %}">
<link rel="stylesheet" href="{% static 'umap/content.css' %}">
<link rel="stylesheet" href="{% static 'umap/nav.css' %}">
<link rel="stylesheet" href="{% static 'umap/font.css' %}" />
<link rel="stylesheet" href="{% static 'umap/base.css' %}" />
<link rel="stylesheet" href="{% static 'umap/content.css' %}" />
<link rel="stylesheet" href="{% static 'umap/nav.css' %}" />
<link rel="stylesheet" href="{% static 'umap/map.css' %}" />
<link rel="stylesheet" href="{% static 'umap/theme.css' %}">
<link rel="stylesheet" href="{% static 'umap/theme.css' %}" />

View file

@ -6,25 +6,25 @@
<script src="{% static 'umap/vendors/hash/leaflet-hash.js' %}" defer></script>
<script src="{% static 'umap/vendors/i18n/Leaflet.i18n.js' %}" defer></script>
<script src="{% static 'umap/vendors/editinosm/Leaflet.EditInOSM.js' %}" defer></script>
<script src="{% static 'umap/vendors/minimap/Control.MiniMap.js' %}" defer></script>
<script src="{% static 'umap/vendors/minimap/Control.MiniMap.min.js' %}" defer></script>
<script src="{% static 'umap/vendors/csv2geojson/csv2geojson.js' %}" defer></script>
<script src="{% static 'umap/vendors/togeojson/togeojson.js' %}" defer></script>
<script src="{% static 'umap/vendors/togeojson/togeojson.umd.js' %}" defer></script>
<script src="{% static 'umap/vendors/osmtogeojson/osmtogeojson.js' %}" defer></script>
<script src="{% static 'umap/vendors/loading/Control.Loading.js' %}" defer></script>
<script src="{% static 'umap/vendors/markercluster/leaflet.markercluster-src.js' %}" defer></script>
<script src="{% static 'umap/vendors/contextmenu/leaflet.contextmenu.js' %}" defer></script>
<script src="{% static 'umap/vendors/markercluster/leaflet.markercluster.js' %}" defer></script>
<script src="{% static 'umap/vendors/contextmenu/leaflet.contextmenu.min.js' %}" defer></script>
<script src="{% static 'umap/vendors/photon/leaflet.photon.js' %}" defer></script>
<script src="{% static 'umap/vendors/georsstogeojson/GeoRSSToGeoJSON.js' %}" defer></script>
<script src="{% static 'umap/vendors/heat/leaflet-heat.js' %}" defer></script>
<script src="{% static 'umap/vendors/fullscreen/Leaflet.fullscreen.js' %}" defer></script>
<script src="{% static 'umap/vendors/toolbar/leaflet.toolbar-src.js' %}" defer></script>
<script src="{% static 'umap/vendors/fullscreen/Leaflet.fullscreen.min.js' %}" defer></script>
<script src="{% static 'umap/vendors/toolbar/leaflet.toolbar.js' %}" defer></script>
<script src="{% static 'umap/vendors/formbuilder/Leaflet.FormBuilder.js' %}" defer></script>
<script src="{% static 'umap/vendors/measurable/Leaflet.Measurable.js' %}" defer></script>
<script src="{% static 'umap/vendors/togpx/togpx.js' %}" defer></script>
<script src="{% static 'umap/vendors/iconlayers/iconLayers.js' %}" defer></script>
<script src="{% static 'umap/vendors/tokml/tokml.js' %}" defer></script>
<script src="{% static 'umap/vendors/locatecontrol/L.Control.Locate.js' %}" defer></script>
<script src="{% static 'umap/vendors/dompurify/purify.js' %}" defer></script>
<script src="{% static 'umap/vendors/locatecontrol/L.Control.Locate.min.js' %}" defer></script>
<script src="{% static 'umap/vendors/dompurify/purify.min.js' %}" defer></script>
<script src="{% static 'umap/vendors/colorbrewer/colorbrewer.js' %}" defer></script>
<script src="{% static 'umap/vendors/simple-statistics/simple-statistics.min.js' %}" defer></script>
{% if locale %}