From 357bf03aa892129a8514b4dfd3dc91c09cdc242d Mon Sep 17 00:00:00 2001 From: Robert Marshall Date: Tue, 30 Mar 2021 10:13:32 +0100 Subject: [PATCH 1/2] Minify CSS and Gov JS --- .../ApplyToBecomeInternal/gulpfile.js | 7 +- .../ApplyToBecomeInternal/package-lock.json | 79 +++++++++++++++++++ .../ApplyToBecomeInternal/package.json | 2 + 3 files changed, 86 insertions(+), 2 deletions(-) diff --git a/ApplyToBecomeInternal/ApplyToBecomeInternal/gulpfile.js b/ApplyToBecomeInternal/ApplyToBecomeInternal/gulpfile.js index 3a65fed2d..46d90c0f1 100644 --- a/ApplyToBecomeInternal/ApplyToBecomeInternal/gulpfile.js +++ b/ApplyToBecomeInternal/ApplyToBecomeInternal/gulpfile.js @@ -4,13 +4,16 @@ var gulp = require("gulp"); var sass = require("gulp-dart-sass"); var async = require("async"); var rename = require("gulp-rename"); +var cleanCSS = require('gulp-clean-css'); +var uglify = require('gulp-uglify'); const buildSass = () => gulp.src("wwwroot/css/*.scss") .pipe(sass().on("error", sass.logError)) + .pipe(cleanCSS()) .pipe(gulp.dest("wwwroot/css")); const copyGovukAssets = () => gulp.src(["node_modules/govuk-frontend/govuk/assets/**/*"]).pipe(gulp.dest("wwwroot/assets")).on("end", () => - gulp.src(["node_modules/govuk-frontend/govuk/all.js"]).pipe(rename("govuk.js")).pipe(gulp.dest("wwwroot/js/"))); + gulp.src(["node_modules/govuk-frontend/govuk/all.js"]).pipe(uglify()).pipe(rename("govuk.js")).pipe(gulp.dest("wwwroot/js/"))); gulp.task("sass", buildSass); @@ -23,6 +26,6 @@ gulp.task("copy-gov-fe-assets", copyGovukAssets); gulp.task("build-fe", () => { return async.series([ (next) => buildSass().on("end", next), - (next) => copyGovukAssets().on("end", next) + (next) => copyGovukAssets().on("end", next), ]) }); \ No newline at end of file diff --git a/ApplyToBecomeInternal/ApplyToBecomeInternal/package-lock.json b/ApplyToBecomeInternal/ApplyToBecomeInternal/package-lock.json index 80b182f57..90995495e 100644 --- a/ApplyToBecomeInternal/ApplyToBecomeInternal/package-lock.json +++ b/ApplyToBecomeInternal/ApplyToBecomeInternal/package-lock.json @@ -372,6 +372,21 @@ } } }, + "clean-css": { + "version": "4.2.3", + "resolved": "https://registry.npmjs.org/clean-css/-/clean-css-4.2.3.tgz", + "integrity": "sha512-VcMWDN54ZN/DS+g58HYL5/n4Zrqe8vHJpGA8KdgUXFU4fuP/aHNw8eld9SyEIyabIMJX/0RaY/fplOo5hYLSFA==", + "requires": { + "source-map": "~0.6.0" + }, + "dependencies": { + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==" + } + } + }, "cliui": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/cliui/-/cliui-3.2.0.tgz", @@ -1274,6 +1289,27 @@ } } }, + "gulp-clean-css": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/gulp-clean-css/-/gulp-clean-css-4.3.0.tgz", + "integrity": "sha512-mGyeT3qqFXTy61j0zOIciS4MkYziF2U594t2Vs9rUnpkEHqfu6aDITMp8xOvZcvdX61Uz3y1mVERRYmjzQF5fg==", + "requires": { + "clean-css": "4.2.3", + "plugin-error": "1.0.1", + "through2": "3.0.1", + "vinyl-sourcemaps-apply": "0.2.1" + }, + "dependencies": { + "through2": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/through2/-/through2-3.0.1.tgz", + "integrity": "sha512-M96dvTalPT3YbYLaKaCuwu+j06D/8Jfib0o/PxbVt6Amhv3dUAtW6rTV1jPgJSBG83I/e04Y6xkVdVhSRhi0ww==", + "requires": { + "readable-stream": "2 || 3" + } + } + } + }, "gulp-dart-sass": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/gulp-dart-sass/-/gulp-dart-sass-1.0.2.tgz", @@ -1294,6 +1330,23 @@ "resolved": "https://registry.npmjs.org/gulp-rename/-/gulp-rename-2.0.0.tgz", "integrity": "sha512-97Vba4KBzbYmR5VBs9mWmK+HwIf5mj+/zioxfZhOKeXtx5ZjBk57KFlePf5nxq9QsTtFl0ejnHE3zTC9MHXqyQ==" }, + "gulp-uglify": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/gulp-uglify/-/gulp-uglify-3.0.2.tgz", + "integrity": "sha512-gk1dhB74AkV2kzqPMQBLA3jPoIAPd/nlNzP2XMDSG8XZrqnlCiDGAqC+rZOumzFvB5zOphlFh6yr3lgcAb/OOg==", + "requires": { + "array-each": "^1.0.1", + "extend-shallow": "^3.0.2", + "gulplog": "^1.0.0", + "has-gulplog": "^0.1.0", + "isobject": "^3.0.1", + "make-error-cause": "^1.1.1", + "safe-buffer": "^5.1.2", + "through2": "^2.0.0", + "uglify-js": "^3.0.5", + "vinyl-sourcemaps-apply": "^0.2.0" + } + }, "gulplog": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/gulplog/-/gulplog-1.0.0.tgz", @@ -1315,6 +1368,14 @@ "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=" }, + "has-gulplog": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/has-gulplog/-/has-gulplog-0.1.0.tgz", + "integrity": "sha1-ZBTIKRNpfaUVkDl9r7EvIpZ4Ec4=", + "requires": { + "sparkles": "^1.0.0" + } + }, "has-symbols": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", @@ -1670,6 +1731,19 @@ "resolved": "https://registry.npmjs.org/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz", "integrity": "sha1-4j8/nE+Pvd6HJSnBBxhXoIblzO8=" }, + "make-error": { + "version": "1.3.6", + "resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz", + "integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==" + }, + "make-error-cause": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/make-error-cause/-/make-error-cause-1.2.2.tgz", + "integrity": "sha1-3wOI/NCzeBbf8KX7gQiTl3fcvJ0=", + "requires": { + "make-error": "^1.2.0" + } + }, "make-iterator": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/make-iterator/-/make-iterator-1.0.1.tgz", @@ -2734,6 +2808,11 @@ "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=" }, + "uglify-js": { + "version": "3.13.3", + "resolved": "https://registry.npmjs.org/uglify-js/-/uglify-js-3.13.3.tgz", + "integrity": "sha512-otIc7O9LyxpUcQoXzj2hL4LPWKklO6LJWoJUzNa8A17Xgi4fOeDC8FBDOLHnC/Slo1CQgsZMcM6as0M76BZaig==" + }, "unc-path-regex": { "version": "0.1.2", "resolved": "https://registry.npmjs.org/unc-path-regex/-/unc-path-regex-0.1.2.tgz", diff --git a/ApplyToBecomeInternal/ApplyToBecomeInternal/package.json b/ApplyToBecomeInternal/ApplyToBecomeInternal/package.json index 354841892..e2291c717 100644 --- a/ApplyToBecomeInternal/ApplyToBecomeInternal/package.json +++ b/ApplyToBecomeInternal/ApplyToBecomeInternal/package.json @@ -12,8 +12,10 @@ "async": "^3.2.0", "govuk-frontend": "^3.11.0", "gulp": "^4.0.2", + "gulp-clean-css": "^4.3.0", "gulp-dart-sass": "^1.0.2", "gulp-rename": "^2.0.0", + "gulp-uglify": "^3.0.2", "sass": "^1.32.8" } } From d4a84211fa910c072c9709b93f85766de54ea716 Mon Sep 17 00:00:00 2001 From: Robert Marshall Date: Tue, 30 Mar 2021 10:14:55 +0100 Subject: [PATCH 2/2] Minify CSS and Gov JS --- ApplyToBecomeInternal/ApplyToBecomeInternal/gulpfile.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/ApplyToBecomeInternal/ApplyToBecomeInternal/gulpfile.js b/ApplyToBecomeInternal/ApplyToBecomeInternal/gulpfile.js index 46d90c0f1..8c47d1d22 100644 --- a/ApplyToBecomeInternal/ApplyToBecomeInternal/gulpfile.js +++ b/ApplyToBecomeInternal/ApplyToBecomeInternal/gulpfile.js @@ -26,6 +26,6 @@ gulp.task("copy-gov-fe-assets", copyGovukAssets); gulp.task("build-fe", () => { return async.series([ (next) => buildSass().on("end", next), - (next) => copyGovukAssets().on("end", next), + (next) => copyGovukAssets().on("end", next) ]) -}); \ No newline at end of file +});