@videinfra/static-website-builder 1.5.1 → 1.5.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/package.json +1 -1
- package/tasks/data/get-data.js +23 -1
- package/tasks/html/task.js +22 -19
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
|
|
|
4
4
|
The format is based on [Keep a Changelog](http://keepachangelog.com/)
|
|
5
5
|
and this project adheres to [Semantic Versioning](http://semver.org/).
|
|
6
6
|
|
|
7
|
+
## [1.5.2] - 2022-06-17
|
|
8
|
+
### Updated
|
|
9
|
+
- In build mode prevent data from being read more than once
|
|
10
|
+
|
|
7
11
|
## [1.5.1] - 2022-04-14
|
|
8
12
|
### Fixed
|
|
9
13
|
- Dependency update
|
package/package.json
CHANGED
package/tasks/data/get-data.js
CHANGED
|
@@ -10,7 +10,7 @@ const getFileNamesSync = require('../../lib/get-file-names');
|
|
|
10
10
|
const camelizeFileName = require('../../lib/camelize-file-name');
|
|
11
11
|
|
|
12
12
|
|
|
13
|
-
|
|
13
|
+
function getData () {
|
|
14
14
|
const folders = getPaths.getSourcePaths('data');
|
|
15
15
|
const extensions = getConfig.getTaskConfig('data', 'extensions');
|
|
16
16
|
const loaders = getConfig.getTaskConfig('data', 'loaders');
|
|
@@ -63,3 +63,25 @@ module.exports = function getData () {
|
|
|
63
63
|
|
|
64
64
|
return data;
|
|
65
65
|
}
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
let cache = null;
|
|
69
|
+
|
|
70
|
+
module.exports = function (options) {
|
|
71
|
+
const build = options && !!options.build;
|
|
72
|
+
|
|
73
|
+
return function () {
|
|
74
|
+
if (build) {
|
|
75
|
+
// Cache during full build
|
|
76
|
+
if (!cache) {
|
|
77
|
+
cache = getData();
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return cache;
|
|
81
|
+
} else {
|
|
82
|
+
// Don't cache during watch build
|
|
83
|
+
cache = null;
|
|
84
|
+
return getData();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
package/tasks/html/task.js
CHANGED
|
@@ -53,36 +53,39 @@ const getEngine = memoize(function () {
|
|
|
53
53
|
return engine ? engine() : (() => {});
|
|
54
54
|
});
|
|
55
55
|
|
|
56
|
+
function html (options) {
|
|
57
|
+
const build = options && !!options.build;
|
|
56
58
|
|
|
57
|
-
function html () {
|
|
58
|
-
|
|
59
|
-
|
|
59
|
+
return function html () {
|
|
60
|
+
return gulp.src(getGlobPaths())
|
|
61
|
+
.pipe(taskStart())
|
|
60
62
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
63
|
+
// Faster incremental builds, skip files which didn't changed or their dependencies didn't changed
|
|
64
|
+
.pipe(gulpif(!!getConfig.getTaskConfig('html', 'dependents'), cached('html')))
|
|
65
|
+
.pipe(gulpif(!!getConfig.getTaskConfig('html', 'dependents'), dependents(getConfig.getTaskConfig('dependents'))))
|
|
64
66
|
|
|
65
|
-
|
|
66
|
-
|
|
67
|
+
// Prevent file from being rendered if it's in the ignore list
|
|
68
|
+
.pipe(ignore.exclude(getGlobIgnorePaths(), {}))
|
|
67
69
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
70
|
+
// Preprocess using TWIG
|
|
71
|
+
.pipe(gulpif(!!getConfig.getTaskConfig('html', 'engine'), data(getData({ build: build }))))
|
|
72
|
+
.pipe(gulpif(!!getConfig.getTaskConfig('html', 'engine'), getEngine()))
|
|
71
73
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
+
// Minify
|
|
75
|
+
.pipe(gulpif(!!getConfig.getTaskConfig('html', 'htmlmin'), htmlmin(getConfig.getTaskConfig('html', 'htmlmin'))))
|
|
74
76
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
+
.pipe(taskBeforeDest())
|
|
78
|
+
.pipe(gulp.dest(getPaths.getDestPath('html')))
|
|
77
79
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
+
// Reload on change
|
|
81
|
+
.pipe(taskEnd());
|
|
82
|
+
};
|
|
80
83
|
}
|
|
81
84
|
|
|
82
85
|
function htmlWatch () {
|
|
83
|
-
return taskWatch(getWatchGlobPaths(), html);
|
|
86
|
+
return taskWatch(getWatchGlobPaths(), html({ build: false }));
|
|
84
87
|
}
|
|
85
88
|
|
|
86
89
|
|
|
87
|
-
exports.build = html;
|
|
90
|
+
exports.build = html({ build: true });
|
|
88
91
|
exports.watch = htmlWatch;
|