mirror of
https://github.com/thegeeklab/hugo-geekblog.git
synced 2024-11-21 20:50:40 +00:00
pre-hash static css/js assets
This commit is contained in:
parent
7015f9f78d
commit
f37db730d5
1
.gitignore
vendored
1
.gitignore
vendored
@ -15,6 +15,7 @@ static/favicon/
|
||||
static/fonts/GeekblogIcons.*
|
||||
resources/
|
||||
exampleSite/resources/
|
||||
data/assets.json
|
||||
|
||||
# testing
|
||||
.lighthouseci/
|
||||
|
3
data/assets-static.json
Normal file
3
data/assets-static.json
Normal file
@ -0,0 +1,3 @@
|
||||
{
|
||||
"custom.css": "custom.css"
|
||||
}
|
@ -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"
|
||||
}
|
29
gulpfile.js
29
gulpfile.js
@ -10,6 +10,7 @@ const path = require("path");
|
||||
const fs = require("fs");
|
||||
|
||||
const svgSprite = require("gulp-svg-sprite");
|
||||
const rev = require("gulp-rev");
|
||||
|
||||
var CSSDEST = "static/";
|
||||
var FAVICON_DATA_FILE = "tmp/faviconData.json";
|
||||
@ -169,21 +170,39 @@ gulp.task("iconfont", function () {
|
||||
.pipe(
|
||||
iconfont({
|
||||
startUnicode: lastUnicode,
|
||||
fontName: "GeekblogIcons", // required
|
||||
prependUnicode: true, // recommended option
|
||||
fontName: "GeekblogIcons",
|
||||
prependUnicode: true,
|
||||
normalize: true,
|
||||
fontHeight: 1001,
|
||||
centerHorizontally: true,
|
||||
formats: ["woff", "woff2"], // default, 'woff2' and 'svg' are available
|
||||
timestamp: TIMESTAMP, // recommended to get consistent builds when watching files
|
||||
formats: ["woff", "woff2"],
|
||||
timestamp: TIMESTAMP,
|
||||
})
|
||||
)
|
||||
.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(
|
||||
"default",
|
||||
gulp.series("sass", "svg-sprite", "iconfont", "favicon-generate")
|
||||
gulp.series("sass", "svg-sprite", "iconfont", "favicon-generate", "asset-rev")
|
||||
);
|
||||
|
||||
gulp.task("devel", function () {
|
||||
|
93
package-lock.json
generated
93
package-lock.json
generated
@ -1840,6 +1840,15 @@
|
||||
"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": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/flagged-respawn/-/flagged-respawn-1.0.1.tgz",
|
||||
@ -2855,6 +2864,22 @@
|
||||
"integrity": "sha512-97Vba4KBzbYmR5VBs9mWmK+HwIf5mj+/zioxfZhOKeXtx5ZjBk57KFlePf5nxq9QsTtFl0ejnHE3zTC9MHXqyQ==",
|
||||
"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": {
|
||||
"version": "4.1.0",
|
||||
"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": {
|
||||
"version": "2.0.4",
|
||||
"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": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
@ -5590,6 +5627,21 @@
|
||||
"integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==",
|
||||
"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": {
|
||||
"version": "0.5.0",
|
||||
"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": {
|
||||
"version": "0.5.7",
|
||||
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz",
|
||||
@ -6447,6 +6508,25 @@
|
||||
"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": {
|
||||
"version": "1.0.0",
|
||||
"resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz",
|
||||
@ -7278,6 +7358,19 @@
|
||||
"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": {
|
||||
"version": "3.0.3",
|
||||
"resolved": "https://registry.npmjs.org/vinyl-fs/-/vinyl-fs-3.0.3.tgz",
|
||||
|
@ -21,6 +21,7 @@
|
||||
"gulp-iconfont": "10.0.3",
|
||||
"gulp-real-favicon": "0.3.2",
|
||||
"gulp-rename": "2.0.0",
|
||||
"gulp-rev": "^9.0.0",
|
||||
"gulp-sass": "4.1.0",
|
||||
"gulp-svg-sprite": "1.5.0",
|
||||
"prettier": "2.1.2",
|
||||
|
Loading…
Reference in New Issue
Block a user