pre-hash static css/js assets

This commit is contained in:
Robert Kaussow 2020-11-22 14:01:47 +01:00
parent 7015f9f78d
commit f37db730d5
No known key found for this signature in database
GPG Key ID: 65362AE74AF98B61
6 changed files with 122 additions and 13 deletions

1
.gitignore vendored
View File

@ -15,6 +15,7 @@ static/favicon/
static/fonts/GeekblogIcons.* static/fonts/GeekblogIcons.*
resources/ resources/
exampleSite/resources/ exampleSite/resources/
data/assets.json
# testing # testing
.lighthouseci/ .lighthouseci/

3
data/assets-static.json Normal file
View File

@ -0,0 +1,3 @@
{
"custom.css": "custom.css"
}

View File

@ -1,8 +0,0 @@
{
"main.min.css": "main.min.css",
"mobile.min.css": "mobile.min.css",
"print.min.css": "print.min.css",
"custom.css": "custom.css",
"js/clipboard.min.js": "js/clipboard.min.js",
"js/mermaid.min.js": "js/mermaid.min.js"
}

View File

@ -10,6 +10,7 @@ const path = require("path");
const fs = require("fs"); const fs = require("fs");
const svgSprite = require("gulp-svg-sprite"); const svgSprite = require("gulp-svg-sprite");
const rev = require("gulp-rev");
var CSSDEST = "static/"; var CSSDEST = "static/";
var FAVICON_DATA_FILE = "tmp/faviconData.json"; var FAVICON_DATA_FILE = "tmp/faviconData.json";
@ -169,21 +170,39 @@ gulp.task("iconfont", function () {
.pipe( .pipe(
iconfont({ iconfont({
startUnicode: lastUnicode, startUnicode: lastUnicode,
fontName: "GeekblogIcons", // required fontName: "GeekblogIcons",
prependUnicode: true, // recommended option prependUnicode: true,
normalize: true, normalize: true,
fontHeight: 1001, fontHeight: 1001,
centerHorizontally: true, centerHorizontally: true,
formats: ["woff", "woff2"], // default, 'woff2' and 'svg' are available formats: ["woff", "woff2"],
timestamp: TIMESTAMP, // recommended to get consistent builds when watching files timestamp: TIMESTAMP,
}) })
) )
.pipe(gulp.dest("static/fonts/")); .pipe(gulp.dest("static/fonts/"));
}); });
gulp.task("asset-rev", function () {
return gulp
.src(["static/*!(custom).min.css", "static/js/*.min.js"], {
base: "static",
})
.pipe(gulp.dest("tmp/assets"))
.pipe(rev())
.pipe(gulp.dest("tmp/assets"))
.pipe(
rev.manifest("data/assets-static.json", {
base: "data",
merge: true,
})
)
.pipe(rename("assets.json"))
.pipe(gulp.dest("data"));
});
gulp.task( gulp.task(
"default", "default",
gulp.series("sass", "svg-sprite", "iconfont", "favicon-generate") gulp.series("sass", "svg-sprite", "iconfont", "favicon-generate", "asset-rev")
); );
gulp.task("devel", function () { gulp.task("devel", function () {

93
package-lock.json generated
View File

@ -1840,6 +1840,15 @@
"parse-filepath": "^1.0.1" "parse-filepath": "^1.0.1"
} }
}, },
"first-chunk-stream": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/first-chunk-stream/-/first-chunk-stream-2.0.0.tgz",
"integrity": "sha1-G97NuOCDwGZLkZRVgVd6Q6nzHXA=",
"dev": true,
"requires": {
"readable-stream": "^2.0.2"
}
},
"flagged-respawn": { "flagged-respawn": {
"version": "1.0.1", "version": "1.0.1",
"resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.1.tgz", "resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.1.tgz",
@ -2855,6 +2864,22 @@
"integrity": "sha512-97Vba4KBzbYmR5VBs9mWmK+HwIf5mj+/zioxfZhOKeXtx5ZjBk57KFlePf5nxq9QsTtFl0ejnHE3zTC9MHXqyQ==", "integrity": "sha512-97Vba4KBzbYmR5VBs9mWmK+HwIf5mj+/zioxfZhOKeXtx5ZjBk57KFlePf5nxq9QsTtFl0ejnHE3zTC9MHXqyQ==",
"dev": true "dev": true
}, },
"gulp-rev": {
"version": "9.0.0",
"resolved": "https://registry.npmjs.org/gulp-rev/-/gulp-rev-9.0.0.tgz",
"integrity": "sha512-Ytx/uzDA2xNxHlPG8GReS1ut00msd0HlKDk9Ai/0xF2yvg+DAeGRAviCFlQzQmdZtqAoXznYspwWoGEoxDvhyA==",
"dev": true,
"requires": {
"modify-filename": "^1.1.0",
"plugin-error": "^1.0.1",
"rev-hash": "^2.0.0",
"rev-path": "^2.0.0",
"sort-keys": "^2.0.0",
"through2": "^2.0.0",
"vinyl": "^2.1.0",
"vinyl-file": "^3.0.0"
}
},
"gulp-sass": { "gulp-sass": {
"version": "4.1.0", "version": "4.1.0",
"resolved": "https://registry.npmjs.org/gulp-sass/-/gulp-sass-4.1.0.tgz", "resolved": "https://registry.npmjs.org/gulp-sass/-/gulp-sass-4.1.0.tgz",
@ -3460,6 +3485,12 @@
} }
} }
}, },
"is-plain-obj": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz",
"integrity": "sha1-caUMhCnfync8kqOQpKA7OfzVHT4=",
"dev": true
},
"is-plain-object": { "is-plain-object": {
"version": "2.0.4", "version": "2.0.4",
"resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz",
@ -4456,6 +4487,12 @@
} }
} }
}, },
"modify-filename": {
"version": "1.1.0",
"resolved": "https://registry.npmjs.org/modify-filename/-/modify-filename-1.1.0.tgz",
"integrity": "sha1-mi3sg4Bvuy2XXyK+7IWcoms5OqE=",
"dev": true
},
"ms": { "ms": {
"version": "2.0.0", "version": "2.0.0",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
@ -5590,6 +5627,21 @@
"integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==",
"dev": true "dev": true
}, },
"rev-hash": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/rev-hash/-/rev-hash-2.0.0.tgz",
"integrity": "sha1-dyCiNu0MJY3z5kvsA+wEiwW5JMQ=",
"dev": true
},
"rev-path": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/rev-path/-/rev-path-2.0.0.tgz",
"integrity": "sha512-G5R2L9gYu9kEuqPfIFgO9gO+OhBWOAT83HyauOQmGHO6y9Fsa4acv+XsmNhNDrod0HDh1/VxJRmsffThzeHJlQ==",
"dev": true,
"requires": {
"modify-filename": "^1.0.0"
}
},
"rfg-api": { "rfg-api": {
"version": "0.5.0", "version": "0.5.0",
"resolved": "https://registry.npmjs.org/rfg-api/-/rfg-api-0.5.0.tgz", "resolved": "https://registry.npmjs.org/rfg-api/-/rfg-api-0.5.0.tgz",
@ -6195,6 +6247,15 @@
} }
} }
}, },
"sort-keys": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/sort-keys/-/sort-keys-2.0.0.tgz",
"integrity": "sha1-ZYU1WEhh7JfXMNbPQYIuH1ZoQSg=",
"dev": true,
"requires": {
"is-plain-obj": "^1.0.0"
}
},
"source-map": { "source-map": {
"version": "0.5.7", "version": "0.5.7",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
@ -6447,6 +6508,25 @@
"is-utf8": "^0.2.0" "is-utf8": "^0.2.0"
} }
}, },
"strip-bom-buf": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/strip-bom-buf/-/strip-bom-buf-1.0.0.tgz",
"integrity": "sha1-HLRar1dTD0yvhsf3UXnSyaUd1XI=",
"dev": true,
"requires": {
"is-utf8": "^0.2.1"
}
},
"strip-bom-stream": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/strip-bom-stream/-/strip-bom-stream-2.0.0.tgz",
"integrity": "sha1-+H217yYT9paKpUWr/h7HKLaoKco=",
"dev": true,
"requires": {
"first-chunk-stream": "^2.0.0",
"strip-bom": "^2.0.0"
}
},
"strip-eof": { "strip-eof": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
@ -7278,6 +7358,19 @@
"replace-ext": "^1.0.0" "replace-ext": "^1.0.0"
} }
}, },
"vinyl-file": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/vinyl-file/-/vinyl-file-3.0.0.tgz",
"integrity": "sha1-sQTZ5ECf+jJfqt1SBkLQo7SIs2U=",
"dev": true,
"requires": {
"graceful-fs": "^4.1.2",
"pify": "^2.3.0",
"strip-bom-buf": "^1.0.0",
"strip-bom-stream": "^2.0.0",
"vinyl": "^2.0.1"
}
},
"vinyl-fs": { "vinyl-fs": {
"version": "3.0.3", "version": "3.0.3",
"resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-3.0.3.tgz", "resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-3.0.3.tgz",

View File

@ -21,6 +21,7 @@
"gulp-iconfont": "10.0.3", "gulp-iconfont": "10.0.3",
"gulp-real-favicon": "0.3.2", "gulp-real-favicon": "0.3.2",
"gulp-rename": "2.0.0", "gulp-rename": "2.0.0",
"gulp-rev": "^9.0.0",
"gulp-sass": "4.1.0", "gulp-sass": "4.1.0",
"gulp-svg-sprite": "1.5.0", "gulp-svg-sprite": "1.5.0",
"prettier": "2.1.2", "prettier": "2.1.2",