From 13beef1516750fbb797516f7fc38ce2916e68f89 Mon Sep 17 00:00:00 2001 From: George Goodall Date: Fri, 12 Apr 2024 10:54:27 +0100 Subject: [PATCH 1/2] add rollup for maplibre --- Makefile | 1 + application/templates/national-map.html | 2 +- package.json | 7 ++++--- rollup.config.js | 10 ++++++++++ 4 files changed, 16 insertions(+), 4 deletions(-) create mode 100644 rollup.config.js diff --git a/Makefile b/Makefile index 0f377e7c..08533840 100644 --- a/Makefile +++ b/Makefile @@ -110,6 +110,7 @@ govukAssets:: npx nps copy.govukAssets javascripts: + npm run build rsync -r assets/javascripts static/ robots: diff --git a/application/templates/national-map.html b/application/templates/national-map.html index 83d5a309..76e0d138 100644 --- a/application/templates/national-map.html +++ b/application/templates/national-map.html @@ -14,7 +14,7 @@ %} {%- block mapAssets %} - + {{ super() }} {% endblock -%} diff --git a/package.json b/package.json index 2c98795b..e8ca351f 100644 --- a/package.json +++ b/package.json @@ -31,13 +31,14 @@ "test": "vitest run", "coverage": "vitest run --coverage", "test-unit": "vitest run --dir tests/unit/javascript", - "test-integration": "vitest run --dir tests/integration/javascript" + "test-integration": "vitest run --dir tests/integration/javascript", + "build": "rollup -c" }, "dependencies": { "copyfiles": "^2.4.1", "govuk-frontend": "4.2.0", - "node-sass": "^9.0.0", - "nps": "^5.10.0" + "maplibre-gl": "^4.1.2", + "node-sass": "^9.0.0" }, "devDependencies": { "@vitest/coverage-v8": "^0.34.1", diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 00000000..57ea7535 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,10 @@ +// get the config object from the package file +module.exports = [ + { + input: `./node_modules/maplibre-gl/dist/maplibre-gl.js`, + output: { + file: `static/javascripts/maplibre-gl.js`, + format: "iife", + } + }, +]; From 8144154dc6ef404796bc2d9224f76c3ac48b5c0a Mon Sep 17 00:00:00 2001 From: George Goodall Date: Fri, 12 Apr 2024 11:16:18 +0100 Subject: [PATCH 2/2] add css and script tags to other files --- Makefile | 1 + application/templates/entity.html | 4 ++-- application/templates/national-map.html | 2 +- application/templates/search.html | 4 ++-- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/Makefile b/Makefile index 08533840..5eeddcbc 100644 --- a/Makefile +++ b/Makefile @@ -123,6 +123,7 @@ frontend: make stylesheets make govukAssets rsync -r assets/images static/ + cp node_modules/maplibre-gl/dist/maplibre-gl.css static/stylesheets/maplibre-gl.css frontend-all: clean frontend diff --git a/application/templates/entity.html b/application/templates/entity.html index d2c7147b..416daa99 100644 --- a/application/templates/entity.html +++ b/application/templates/entity.html @@ -29,8 +29,8 @@ {% endblock %} {%- block mapAssets %} - - + + {{ super() }} {% endblock -%} diff --git a/application/templates/national-map.html b/application/templates/national-map.html index 76e0d138..24aee274 100644 --- a/application/templates/national-map.html +++ b/application/templates/national-map.html @@ -15,7 +15,7 @@ {%- block mapAssets %} - + {{ super() }} {% endblock -%} diff --git a/application/templates/search.html b/application/templates/search.html index 8dff8e4b..acd28251 100644 --- a/application/templates/search.html +++ b/application/templates/search.html @@ -12,8 +12,8 @@ {% from 'components/pagination/macro.jinja' import appPagination %} {%- block mapAssets %} - - + + {{ super() }} {% endblock -%}