From 273f638888fda22ff9c999fa1889741dcb23588f Mon Sep 17 00:00:00 2001 From: Tom Byers Date: Tue, 29 Jun 2021 21:25:18 +0100 Subject: [PATCH] Return names of JS files to old format It turns out that rollup's 'input' option allows you to define the 'name' property (used in the format string that defines the final name of output files). This can be done by passing in an object containing name:path pairs. For example: 'input': { 'foo': '/path/to/file.js' }, 'output': { 'entryFileNames': '[name].js' } ...will produce 'foo.js' These changes use this feature to return the JavaScript files to the names they had before and updates the HTML to reflect this. See the docs for the input option for more detail: https://www.rollupjs.org/guide/en/#input --- gulpfile.js | 12 +++++++++--- src/alert.html | 4 ++-- src/current-alerts.html | 2 +- src/index.html | 4 ++-- src/opt-out.html | 2 +- src/past-alerts.html | 2 +- src/when-you-get-an-alert.html | 2 +- 7 files changed, 17 insertions(+), 11 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 81bcd118..ea48569c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -67,7 +67,9 @@ const javascripts = { // - deliver it in one bundle // - allow it to run in browsers without support for JS Modules return rollup.rollup({ - input: paths.src + 'javascripts/govuk-frontend-details-init.mjs', + input: { + 'govuk-frontend-details': paths.src + 'javascripts/govuk-frontend-details-init.mjs' + }, plugins: [ // determine module entry points from either 'module' or 'main' fields in package.json rollupPluginNodeResolve.nodeResolve({ @@ -97,7 +99,9 @@ const javascripts = { // - deliver it in one bundle // - allow it to run in browsers without support for JS Modules return rollup.rollup({ - input: paths.src + 'javascripts/sharing-button-init.mjs', + input: { + 'sharing-button': paths.src + 'javascripts/sharing-button-init.mjs' + }, plugins: [ // determine module entry points from either 'module' or 'main' fields in package.json rollupPluginNodeResolve.nodeResolve({ @@ -127,7 +131,9 @@ const javascripts = { // - deliver it in one bundle // - allow it to run in browsers without support for JS Modules return rollup.rollup({ - input: paths.src + 'javascripts/relative-dates-init.mjs', + input: { + 'relative-dates': paths.src + 'javascripts/relative-dates-init.mjs' + }, plugins: [ // determine module entry points from either 'module' or 'main' fields in package.json rollupPluginNodeResolve.nodeResolve({ diff --git a/src/alert.html b/src/alert.html index f71f47a8..85354d91 100644 --- a/src/alert.html +++ b/src/alert.html @@ -92,7 +92,7 @@

{% endblock %} {% block bodyEnd %} - - + + {% endblock %} diff --git a/src/current-alerts.html b/src/current-alerts.html index c205ebd5..dc745b29 100644 --- a/src/current-alerts.html +++ b/src/current-alerts.html @@ -15,7 +15,7 @@ {% endblock %} {% block prefetch %} - + {% endblock %} {% block pageTitleCurrent -%} diff --git a/src/index.html b/src/index.html index e5ceb95a..75e36e6b 100644 --- a/src/index.html +++ b/src/index.html @@ -17,7 +17,7 @@ {% endblock %} {% block prefetch %} - + {% endblock %} {% block pageTitleCurrent -%} @@ -106,5 +106,5 @@

How it works

{% endblock %} {% block bodyEnd %} - + {% endblock %} diff --git a/src/opt-out.html b/src/opt-out.html index b0148fe7..2d02c77d 100644 --- a/src/opt-out.html +++ b/src/opt-out.html @@ -97,5 +97,5 @@

{% endblock %} {% block bodyEnd %} - + {% endblock %} diff --git a/src/past-alerts.html b/src/past-alerts.html index 15a0eeec..bb650120 100644 --- a/src/past-alerts.html +++ b/src/past-alerts.html @@ -15,7 +15,7 @@ {% endblock %} {% block prefetch %} - + {% endblock %} {% block pageTitleCurrent -%} diff --git a/src/when-you-get-an-alert.html b/src/when-you-get-an-alert.html index 36aa479d..57cdce92 100644 --- a/src/when-you-get-an-alert.html +++ b/src/when-you-get-an-alert.html @@ -125,5 +125,5 @@

{% endblock %} {% block bodyEnd %} - + {% endblock %}