@videinfra/static-website-builder 2.4.0 → 2.4.1
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
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
|
+
## [2.4.1] - 2026-04-23
|
|
8
|
+
### Added
|
|
9
|
+
- Allow to specify additional static data for env variables in task config
|
|
10
|
+
|
|
7
11
|
## [2.4.0] - 2026-04-23
|
|
8
12
|
### Added
|
|
9
13
|
- 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/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);
|