@videinfra/static-website-builder 2.4.0 → 2.4.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 +8 -0
- package/init/test/config/config.js +5 -0
- package/init/test/src/javascripts/main.js +1 -0
- package/package.json +1 -1
- package/tasks/env/config.js +4 -1
- package/tasks/env/get-env.js +17 -7
- package/tasks/sitemap/config.js +6 -1
- package/tasks/sitemap/preprocess-config.js +32 -0
- package/tests/build/env.test.js +8 -0
- package/vendor/gulp-sitemap/index.js +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,14 @@ 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
|
+
## [2.4.2] - 2026-04-23
|
|
8
|
+
### Added
|
|
9
|
+
- Multilingual sitemap generation
|
|
10
|
+
|
|
11
|
+
## [2.4.1] - 2026-04-23
|
|
12
|
+
### Added
|
|
13
|
+
- Allow to specify additional static data for env variables in task config
|
|
14
|
+
|
|
7
15
|
## [2.4.0] - 2026-04-23
|
|
8
16
|
### Added
|
|
9
17
|
- Allow to specify builder config file path using `BUILDER_CONFIG_FILE` env variable
|
|
@@ -3,6 +3,7 @@ console.log('Hello from main page!');
|
|
|
3
3
|
console.log('env.host ==', process.env.host);
|
|
4
4
|
console.log('env.foo ==', process.env.foo);
|
|
5
5
|
console.log('env.bar ==', process.env.bar);
|
|
6
|
+
console.log('env.baz ==', process.env.baz);
|
|
6
7
|
console.log('env.typeBoolTrue ==', process.env.typeBoolTrue);
|
|
7
8
|
console.log('env.typeBoolFalse ==', process.env.typeBoolFalse);
|
|
8
9
|
console.log('env.typeNumber ==', process.env.typeNumber);
|
package/package.json
CHANGED
package/tasks/env/config.js
CHANGED
|
@@ -14,7 +14,10 @@ export const env = {
|
|
|
14
14
|
// How env variable names should be remapped
|
|
15
15
|
// Example:
|
|
16
16
|
// map: { 'HOST': 'host', 'RECAPTCHA3_PUBLIC_KEY': 'recaptcha3_site_key' }
|
|
17
|
-
map: {}
|
|
17
|
+
map: {},
|
|
18
|
+
|
|
19
|
+
// Additional data to add to env variables
|
|
20
|
+
data: {},
|
|
18
21
|
};
|
|
19
22
|
|
|
20
23
|
export const paths = {
|
package/tasks/env/get-env.js
CHANGED
|
@@ -88,16 +88,26 @@ const getEnvData = nanomemoize.nanomemoize(function () {
|
|
|
88
88
|
const envOutVariables = {};
|
|
89
89
|
|
|
90
90
|
// Remap property names
|
|
91
|
-
const map = getTaskConfig('env', 'map');
|
|
91
|
+
const map = getTaskConfig('env', 'map') || {};
|
|
92
92
|
|
|
93
93
|
Object.keys(map).forEach((key) => {
|
|
94
94
|
const value = key in envVariables ? envVariables[key] : '';
|
|
95
|
-
const
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
95
|
+
const mappedKey = map[key];
|
|
96
|
+
twigVariables[mappedKey] = normalizeTwigVariable(value);
|
|
97
|
+
envOutVariables[mappedKey] = value;
|
|
98
|
+
jsVariables[`process.env.${mappedKey}`] = escapeJSVariable(value);
|
|
99
|
+
scssVariables.env[mappedKey] = value;
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
// Add additional data
|
|
103
|
+
const data = getTaskConfig('env', 'data') || {};
|
|
104
|
+
|
|
105
|
+
Object.keys(data).forEach((key) => {
|
|
106
|
+
const value = data[key];
|
|
107
|
+
twigVariables[key] = normalizeTwigVariable(value);
|
|
108
|
+
envOutVariables[key] = value;
|
|
109
|
+
jsVariables[`process.env.${key}`] = escapeJSVariable(value);
|
|
110
|
+
scssVariables.env[key] = value;
|
|
101
111
|
});
|
|
102
112
|
|
|
103
113
|
return {
|
package/tasks/sitemap/config.js
CHANGED
|
@@ -23,9 +23,14 @@ export const sitemap = {
|
|
|
23
23
|
},
|
|
24
24
|
|
|
25
25
|
// Remove file extension from the URL
|
|
26
|
-
getLoc: function(siteUrl, loc, entry) {
|
|
26
|
+
getLoc: function (siteUrl, loc, entry) {
|
|
27
27
|
return loc.replace(/\.\w+$/, '');
|
|
28
28
|
},
|
|
29
|
+
|
|
30
|
+
// Remove lastmod, we don't know that
|
|
31
|
+
lastmod: function () {
|
|
32
|
+
return null;
|
|
33
|
+
},
|
|
29
34
|
},
|
|
30
35
|
|
|
31
36
|
// Production only settings, overwrites default settings
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import getEnvData from '../env/get-env.js';
|
|
2
|
+
import { getTaskConfig } from './../../lib/get-config.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Modify configuration
|
|
@@ -14,5 +15,36 @@ export default function preprocessSitemapConfig (config = {}, fullConfig) {
|
|
|
14
15
|
config.sitemap = config.sitemap || {};
|
|
15
16
|
config.sitemap.siteUrl = envData.env.host;
|
|
16
17
|
|
|
18
|
+
// Languages
|
|
19
|
+
const translationConfig = getTaskConfig('translations');
|
|
20
|
+
const locales = translationConfig.locales;
|
|
21
|
+
const defaultLocale = translationConfig.defaultLocale;
|
|
22
|
+
|
|
23
|
+
if (locales.length > 1) {
|
|
24
|
+
// Add all other locales to ignore list
|
|
25
|
+
config.ignore = config.ignore || [];
|
|
26
|
+
config.ignore = config.ignore.concat(locales.map(function(locale) {
|
|
27
|
+
return locale + '/**';
|
|
28
|
+
}));
|
|
29
|
+
|
|
30
|
+
// Set hreflang
|
|
31
|
+
config.sitemap.hreflang = locales.map(function(locale) {
|
|
32
|
+
return {
|
|
33
|
+
lang: locale,
|
|
34
|
+
getHref: function(siteUrl, file, locale) {
|
|
35
|
+
let url;
|
|
36
|
+
|
|
37
|
+
if (locale !== defaultLocale) {
|
|
38
|
+
url = siteUrl + '/' + locale + '/' + file;
|
|
39
|
+
} else {
|
|
40
|
+
url = siteUrl + '/' + file;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return url.replace(/\/{2,}/g, '/').replace(/\/$/, '');
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
|
|
17
49
|
return config;
|
|
18
50
|
}
|
package/tests/build/env.test.js
CHANGED
|
@@ -34,6 +34,14 @@ test('.env and .env.local files loaded', () => {
|
|
|
34
34
|
]);
|
|
35
35
|
});
|
|
36
36
|
|
|
37
|
+
test('Additional ENV data is set', () => {
|
|
38
|
+
return Promise.all([
|
|
39
|
+
fsPromises.readFile(path.resolve(publicPath, 'assets/javascripts/main.js'), { encoding: 'utf8' }).then((js) => {
|
|
40
|
+
expect(js.indexOf('console.log(`env.baz ==`,`bazValue`)')).not.toBe(-1);
|
|
41
|
+
}),
|
|
42
|
+
]);
|
|
43
|
+
});
|
|
44
|
+
|
|
37
45
|
test('process.env available in html/data', () => {
|
|
38
46
|
return fsPromises.readFile(path.resolve(publicPath, 'env.html'), { encoding: 'utf8' }).then((html) => {
|
|
39
47
|
expect(html.indexOf('<p>HOST FROM GLOBAL JS: https://test-local.tld</p>')).not.toBe(-1);
|
|
@@ -50,8 +50,8 @@ module.exports = function (options = {}) {
|
|
|
50
50
|
return callback(new PluginError(pluginName), msg);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
//skip 404
|
|
54
|
-
if (/404\.html?$/i.test(file.relative)) {
|
|
53
|
+
// skip 404 and 500 files
|
|
54
|
+
if (/(404|500)\.html?$/i.test(file.relative)) {
|
|
55
55
|
return callback();
|
|
56
56
|
}
|
|
57
57
|
|