From f1f0361d0020005b90352466b423708d185b087f Mon Sep 17 00:00:00 2001 From: Alistair Laing Date: Wed, 19 Jun 2019 09:21:00 +0100 Subject: [PATCH] Fixes public directory structure MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Some of the changes made before meant that js files were being compiled and placed in a `govuk` directory. This meant that the browser could not find the js files when viewing the page. Current & desired folder structure for `public` when serving up the review app: public ├── components │ ├── accordion │ ├── button │ ├── character-count │ ├── checkboxes │ ├── details │ ├── error-summary │ ├── header │ ├── radios │ └── tabs ├── vendor │ └── polyfills ├── all.js ├── app-ie8.css ├── app-legacy-ie8.css ├── app-legacy.css ├── app.css └── common.js --- tasks/gulp/compile-assets.js | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/tasks/gulp/compile-assets.js b/tasks/gulp/compile-assets.js index a401088d97f..645507de5b9 100644 --- a/tasks/gulp/compile-assets.js +++ b/tasks/gulp/compile-assets.js @@ -28,6 +28,17 @@ const postcsspseudoclasses = require('postcss-pseudo-classes')({ // check if destination flag is dist const isDist = taskArguments.destination === 'dist' || false +// Set the destination +const destinationPath = function () { + if (taskArguments.destination === 'dist') { + return taskArguments.destination + } else if (taskArguments.destination === 'public') { + return taskArguments.destination + } else { + return `${taskArguments.destination}/govuk/` + } +} + const errorHandler = function (error) { // Log the error to the console console.error(error.message) @@ -142,7 +153,6 @@ gulp.task('scss:compile', () => { gulp.task('js:compile', () => { // for dist/ folder we only want compiled 'all.js' file let srcFiles = isDist ? configPaths.src + 'all.js' : configPaths.src + '**/*.js' - let destination = isDist ? taskArguments.destination : taskArguments.destination + '/govuk/' return gulp.src([ srcFiles, @@ -166,5 +176,5 @@ gulp.task('js:compile', () => { }) )) .pipe(eol()) - .pipe(gulp.dest(destination)) + .pipe(gulp.dest(destinationPath)) })