From b436090c64707ab5c83558e99fa1fa35cd2f1442 Mon Sep 17 00:00:00 2001 From: kolaente Date: Mon, 20 Jan 2020 22:41:17 +0100 Subject: [PATCH] Add gulp css hash filename --- .gitignore | 1 + gulpfile.js | 2 ++ layouts/partials/header.html | 6 ++++-- package.json | 1 + yarn.lock | 5 +++++ 5 files changed, 13 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 1affd78..1d99f6a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ .idea/ node_modules/ static/styles/main.css +static/styles/main*.css static/styles/main.css.map diff --git a/gulpfile.js b/gulpfile.js index 4b33426..e4ef66a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -5,6 +5,7 @@ const tar = require('gulp-tar-path'); const gzip = require('gulp-gzip'); const clean = require('gulp-clean'); const cleanCSS = require('gulp-clean-css'); +const hash = require('gulp-hash-filename'); const sources = [ 'archetypes', @@ -40,6 +41,7 @@ gulp.task('sass-prod', () => { .pipe(sourcemaps.init()) .pipe(sass().on('error', sass.logError)) .pipe(cleanCSS()) + .pipe(hash()) .pipe(gulp.dest('./static/styles')); }) diff --git a/layouts/partials/header.html b/layouts/partials/header.html index ff75e30..13ad495 100644 --- a/layouts/partials/header.html +++ b/layouts/partials/header.html @@ -23,8 +23,10 @@ - - + {{ $siteBaseURL := .Site.BaseURL }} + {{ range readDir "../../static/styles" }} + + {{ end }} diff --git a/package.json b/package.json index 7fb4fce..b943a5d 100644 --- a/package.json +++ b/package.json @@ -21,6 +21,7 @@ "gulp-clean": "^0.3.2", "gulp-clean-css": "^4.2.0", "gulp-gzip": "^1.4.0", + "gulp-hash-filename": "^2.0.1", "gulp-sass": "^3.1.0", "gulp-sourcemaps": "^1.9.1", "gulp-tar-path": "^1.0.1" diff --git a/yarn.lock b/yarn.lock index 49796c9..8a01948 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1097,6 +1097,11 @@ gulp-gzip@^1.4.0: stream-to-array "^2.3.0" through2 "^2.0.3" +gulp-hash-filename@^2.0.1: + version "2.0.1" + resolved "https://registry.yarnpkg.com/gulp-hash-filename/-/gulp-hash-filename-2.0.1.tgz#c30656261a9b622d636766e48b8297125b4ddde8" + integrity sha512-pMg5owb8Dt0wqjgPx/TFbU3c5ckD16rrgo0BTm9PQ3pVC1Zsgw7AYx1+DP2t31JoUTeN1/dPuXNWnCNvN/wj7A== + gulp-sass@^3.1.0: version "3.2.1" resolved "https://registry.yarnpkg.com/gulp-sass/-/gulp-sass-3.2.1.tgz#2e3688a96fd8be1c0c01340750c191b2e79fab94"