@videinfra/static-website-builder 2.0.2 → 2.0.4

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.
Files changed (122) hide show
  1. package/.prettierrc +11 -11
  2. package/CHANGELOG.md +214 -210
  3. package/README.md +102 -102
  4. package/bin/builder.js +40 -40
  5. package/eslint.config.js +39 -39
  6. package/gulpfile.js +63 -63
  7. package/init/default/config/config.js +44 -44
  8. package/init/default/src/html/data/global.js +9 -9
  9. package/init/default/src/javascripts/_entries.js +14 -14
  10. package/init/index.js +63 -63
  11. package/init/test/.env +6 -6
  12. package/init/test/.env.local +3 -2
  13. package/init/test/config/config.js +71 -67
  14. package/init/test/src/html/404.twig +12 -12
  15. package/init/test/src/html/data/global.js +10 -10
  16. package/init/test/src/html/env.twig +21 -21
  17. package/init/test/src/html/layouts/base.twig +1 -1
  18. package/init/test/src/html/other.twig +9 -9
  19. package/init/test/src/html/preposition.twig +4 -4
  20. package/init/test/src/javascripts/_entries-alt.js +10 -10
  21. package/init/test/src/javascripts/_entries.js +19 -19
  22. package/init/test/src/javascripts/common.js +13 -13
  23. package/init/test/src/javascripts/main.js +8 -8
  24. package/init/test/src/javascripts/something.ts +9 -9
  25. package/init/test/src/stylesheets/autoprefixer-test.scss +3 -3
  26. package/init/test/src/stylesheets/env-test.scss +28 -28
  27. package/init/test/src/stylesheets/ignore-test.scss +4 -4
  28. package/init/test/src/stylesheets/nested-calc-test.scss +3 -3
  29. package/init/test/src/stylesheets/sub-folder/import-test.scss +2 -2
  30. package/lib/camelize-file-name.js +21 -21
  31. package/lib/generate-gulp-tasks.js +85 -85
  32. package/lib/get-config.js +203 -204
  33. package/lib/get-file-names.js +23 -23
  34. package/lib/get-path.js +102 -102
  35. package/lib/globs-helper.js +243 -243
  36. package/lib/gulp/dynamic-task.js +8 -8
  37. package/lib/gulp/resolve-dynamic-task.js +11 -11
  38. package/lib/gulp/task-before-dest.js +8 -8
  39. package/lib/gulp/task-end.js +10 -10
  40. package/lib/gulp/task-start.js +12 -12
  41. package/lib/gulp/task-watch.js +66 -66
  42. package/lib/init/copy-folder.js +50 -50
  43. package/lib/init/folder-exists.js +10 -10
  44. package/lib/init/get-folder-list.js +16 -16
  45. package/lib/init/merge-package.js +17 -17
  46. package/lib/init/read-package.js +17 -17
  47. package/lib/log-error.js +15 -15
  48. package/lib/merge.js +27 -27
  49. package/lib/run-preprocess.js +32 -32
  50. package/lib/task-order.js +19 -19
  51. package/package.json +68 -68
  52. package/plugins/example/preprocess-config.js +17 -17
  53. package/plugins/example/task.js +55 -55
  54. package/plugins/example.js +38 -38
  55. package/plugins/sass-engine/preprocess-config.js +59 -59
  56. package/plugins/sass.js +41 -41
  57. package/plugins/twig/lodash-filters/filters.js +91 -91
  58. package/plugins/twig/lodash-filters.js +14 -14
  59. package/plugins/twig/symfony-filters/filters.js +102 -102
  60. package/plugins/twig/symfony-filters/preposition_nbsp.js +77 -77
  61. package/plugins/twig/symfony-filters.js +14 -14
  62. package/plugins/twig/symfony-functions/functions.js +31 -31
  63. package/plugins/twig/symfony-functions.js +14 -14
  64. package/plugins/twig-engine/preprocess-config.js +53 -53
  65. package/plugins/twig.js +74 -74
  66. package/tasks/browser-sync/config.js +39 -39
  67. package/tasks/browser-sync/preprocess-config.js +32 -32
  68. package/tasks/browser-sync/task.js +9 -9
  69. package/tasks/clean/config.js +20 -20
  70. package/tasks/clean/preprocess-config.js +19 -19
  71. package/tasks/clean/task.js +7 -7
  72. package/tasks/data/config.js +34 -34
  73. package/tasks/data/data-loader-js.js +14 -14
  74. package/tasks/data/data-loader-json.js +5 -5
  75. package/tasks/data/get-data.js +96 -96
  76. package/tasks/env/config.js +26 -23
  77. package/tasks/env/get-env.js +113 -81
  78. package/tasks/fonts/config.js +24 -24
  79. package/tasks/fonts/task.js +47 -47
  80. package/tasks/global/config.js +7 -7
  81. package/tasks/html/config.js +42 -42
  82. package/tasks/html/task.js +91 -91
  83. package/tasks/icons/config.js +47 -47
  84. package/tasks/icons/preprocess-config.js +60 -60
  85. package/tasks/icons/task.js +56 -56
  86. package/tasks/images/config.js +27 -27
  87. package/tasks/images/task.js +46 -46
  88. package/tasks/javascripts/config.js +69 -69
  89. package/tasks/javascripts/preprocess-config.js +109 -109
  90. package/tasks/javascripts/task.js +86 -86
  91. package/tasks/sitemap/config.js +48 -48
  92. package/tasks/sitemap/preprocess-config.js +18 -18
  93. package/tasks/sitemap/task.js +69 -69
  94. package/tasks/sizereport/config.js +23 -23
  95. package/tasks/sizereport/task.js +16 -16
  96. package/tasks/static/config.js +27 -27
  97. package/tasks/static/task.js +46 -46
  98. package/tasks/stylesheets/config.js +85 -85
  99. package/tasks/stylesheets/preprocess-config.js +41 -41
  100. package/tasks/stylesheets/task.js +73 -73
  101. package/tests/build/build.test.js +153 -153
  102. package/tests/camelize-file-name.test.js +11 -11
  103. package/tests/generate-gulp-tasks.test.js +78 -78
  104. package/tests/glob-helper.test.js +99 -99
  105. package/tests/merge.test.js +10 -10
  106. package/tests/preposition_nbsp.test.js +50 -50
  107. package/tests/run-preprocess.test.js +90 -90
  108. package/tests/sass-stringify.test.js +24 -24
  109. package/tests/sitemap.test.js +12 -12
  110. package/vendor/gulp-rolldown/index.js +151 -151
  111. package/vendor/gulp-rolldown/plugin-raw.js +17 -17
  112. package/vendor/gulp-rolldown/plugin-virtual-entry.js +30 -30
  113. package/vendor/gulp-sass/CHANGELOG.md +168 -168
  114. package/vendor/gulp-sass/LICENSE +20 -20
  115. package/vendor/gulp-sass/README.md +187 -187
  116. package/vendor/gulp-sass/index.js +208 -208
  117. package/vendor/gulp-sass/package.json +61 -61
  118. package/vendor/gulp-sass/sass-stringify.js +32 -32
  119. package/vendor/gulp-twig/LICENSE +20 -20
  120. package/vendor/gulp-twig/README.md +167 -167
  121. package/vendor/gulp-twig/index.js +138 -138
  122. package/vendor/gulp-twig/package.json +44 -44
@@ -1,34 +1,34 @@
1
- import dataLoaderJs from './data-loader-js.js';
2
- import dataLoaderJson from './data-loader-json.js';
3
-
4
- /**
5
- * Data loading for HTML task
6
- * This task doesn't have actual task, instead it's used by 'html' task
7
- */
8
-
9
- export const data = {
10
- extensions: ['js', 'json'],
11
-
12
- // Data loaders for extensions, allows to add custom loaders
13
- loaders: {
14
- js: dataLoaderJs,
15
- json: dataLoaderJson,
16
- },
17
-
18
- // Glob list of files, which to ignore, relative to the data source folder
19
- // see https://gulpjs.com/docs/en/getting-started/explaining-globs/
20
- ignore: [],
21
-
22
- // Group data by filename (without extension + cammelCase)
23
- // eg, person-names.js -> {'personNames': ...}
24
- groupByFileName: false,
25
- };
26
-
27
- /**
28
- * Paths relative to the global src and dest folders
29
- */
30
- export const paths = {
31
- data: {
32
- src: 'html/data',
33
- },
34
- };
1
+ import dataLoaderJs from './data-loader-js.js';
2
+ import dataLoaderJson from './data-loader-json.js';
3
+
4
+ /**
5
+ * Data loading for HTML task
6
+ * This task doesn't have actual task, instead it's used by 'html' task
7
+ */
8
+
9
+ export const data = {
10
+ extensions: ['js', 'json'],
11
+
12
+ // Data loaders for extensions, allows to add custom loaders
13
+ loaders: {
14
+ js: dataLoaderJs,
15
+ json: dataLoaderJson,
16
+ },
17
+
18
+ // Glob list of files, which to ignore, relative to the data source folder
19
+ // see https://gulpjs.com/docs/en/getting-started/explaining-globs/
20
+ ignore: [],
21
+
22
+ // Group data by filename (without extension + cammelCase)
23
+ // eg, person-names.js -> {'personNames': ...}
24
+ groupByFileName: false,
25
+ };
26
+
27
+ /**
28
+ * Paths relative to the global src and dest folders
29
+ */
30
+ export const paths = {
31
+ data: {
32
+ src: 'html/data',
33
+ },
34
+ };
@@ -1,14 +1,14 @@
1
- import { createRequire } from 'node:module';
2
- const require = createRequire(import.meta.url);
3
-
4
- export default function dataLoaderJS (fileName) {
5
- // Re-load script each time this function is called
6
- delete require.cache[require.resolve(fileName)];
7
- const data = require(fileName);
8
-
9
- if (data && Object.prototype.toString.call(data) === '[object Module]') {
10
- return data.default;
11
- } else {
12
- return data;
13
- }
14
- };
1
+ import { createRequire } from 'node:module';
2
+ const require = createRequire(import.meta.url);
3
+
4
+ export default function dataLoaderJS (fileName) {
5
+ // Re-load script each time this function is called
6
+ delete require.cache[require.resolve(fileName)];
7
+ const data = require(fileName);
8
+
9
+ if (data && Object.prototype.toString.call(data) === '[object Module]') {
10
+ return data.default;
11
+ } else {
12
+ return data;
13
+ }
14
+ };
@@ -1,5 +1,5 @@
1
- import fs from 'fs';
2
-
3
- export default function dataLoaderJSON(fileName) {
4
- return JSON.parse(fs.readFileSync(fileName, 'utf8'));
5
- }
1
+ import fs from 'fs';
2
+
3
+ export default function dataLoaderJSON(fileName) {
4
+ return JSON.parse(fs.readFileSync(fileName, 'utf8'));
5
+ }
@@ -1,96 +1,96 @@
1
- import path from 'path';
2
- import reduce from 'lodash/reduce.js';
3
- import micromatch from 'micromatch'; // gulp dependency
4
-
5
- import merge from '../../lib/merge.js';
6
- import { getSourcePaths, getPathConfig } from '../../lib/get-path.js';
7
- import { getTaskConfig } from '../../lib/get-config.js';
8
- import logError from '../../lib/log-error.js';
9
- import getFileNamesSync from '../../lib/get-file-names.js';
10
- import camelizeFileName from '../../lib/camelize-file-name.js';
11
- import getEnvData from '../env/get-env.js';
12
-
13
- function getData() {
14
- const folders = getSourcePaths('data');
15
- const extensions = getTaskConfig('data', 'extensions');
16
- const loaders = getTaskConfig('data', 'loaders');
17
- const ignore = getTaskConfig('data', 'ignore');
18
- const group = getTaskConfig('data', 'groupByFileName');
19
- const envData = getEnvData();
20
-
21
- // Merge into process.env before loading data because these may be used
22
- // in data
23
- merge(process.env, envData.env);
24
-
25
- const data = reduce(
26
- folders,
27
- (data, folder) => {
28
- getFileNamesSync(folder).forEach((fileName) => {
29
- // Ignore files matching 'ignore' list
30
- if (ignore.length && micromatch.isMatch(fileName, ignore)) {
31
- return;
32
- }
33
-
34
- // Ignore files starting with underscore
35
- if (fileName[0] !== '_') {
36
- const extension = fileName.split('.').pop();
37
-
38
- if (extension && extensions.indexOf(extension) !== -1) {
39
- if (extension in loaders) {
40
- try {
41
- const fullFilePath = path.resolve(folder, fileName);
42
- const fileData = loaders[extension](fullFilePath);
43
-
44
- if (group) {
45
- // Group data
46
- const name = camelizeFileName(fileName);
47
- data = merge(data, { [name]: fileData });
48
- } else {
49
- // Merge together
50
- data = merge(data, fileData);
51
- }
52
- } catch (err) {
53
- logError({
54
- message: `Failed to parse "${path.join(getPathConfig().src, getPathConfig().data.src, fileName)}"`,
55
- plugin: 'data',
56
- });
57
- }
58
- } else {
59
- logError({
60
- message: `Data loader for files with "${extension}" extension is not defined in configuration data.loaders property`,
61
- plugin: 'data',
62
- });
63
- }
64
- }
65
- }
66
- });
67
-
68
- return data;
69
- },
70
- {},
71
- );
72
-
73
- // Merge with env variables
74
- return merge(data, envData.twig);
75
- }
76
-
77
- let cache = null;
78
-
79
- export default function (options) {
80
- const build = options && !!options.build;
81
-
82
- return function () {
83
- if (build) {
84
- // Cache during full build
85
- if (!cache) {
86
- cache = getData();
87
- }
88
-
89
- return cache;
90
- } else {
91
- // Don't cache during watch build
92
- cache = null;
93
- return getData();
94
- }
95
- };
96
- }
1
+ import path from 'path';
2
+ import reduce from 'lodash/reduce.js';
3
+ import micromatch from 'micromatch'; // gulp dependency
4
+
5
+ import merge from '../../lib/merge.js';
6
+ import { getSourcePaths, getPathConfig } from '../../lib/get-path.js';
7
+ import { getTaskConfig } from '../../lib/get-config.js';
8
+ import logError from '../../lib/log-error.js';
9
+ import getFileNamesSync from '../../lib/get-file-names.js';
10
+ import camelizeFileName from '../../lib/camelize-file-name.js';
11
+ import getEnvData from '../env/get-env.js';
12
+
13
+ function getData() {
14
+ const folders = getSourcePaths('data');
15
+ const extensions = getTaskConfig('data', 'extensions');
16
+ const loaders = getTaskConfig('data', 'loaders');
17
+ const ignore = getTaskConfig('data', 'ignore');
18
+ const group = getTaskConfig('data', 'groupByFileName');
19
+ const envData = getEnvData();
20
+
21
+ // Merge into process.env before loading data because these may be used
22
+ // in data
23
+ merge(process.env, envData.env);
24
+
25
+ const data = reduce(
26
+ folders,
27
+ (data, folder) => {
28
+ getFileNamesSync(folder).forEach((fileName) => {
29
+ // Ignore files matching 'ignore' list
30
+ if (ignore.length && micromatch.isMatch(fileName, ignore)) {
31
+ return;
32
+ }
33
+
34
+ // Ignore files starting with underscore
35
+ if (fileName[0] !== '_') {
36
+ const extension = fileName.split('.').pop();
37
+
38
+ if (extension && extensions.indexOf(extension) !== -1) {
39
+ if (extension in loaders) {
40
+ try {
41
+ const fullFilePath = path.resolve(folder, fileName);
42
+ const fileData = loaders[extension](fullFilePath);
43
+
44
+ if (group) {
45
+ // Group data
46
+ const name = camelizeFileName(fileName);
47
+ data = merge(data, { [name]: fileData });
48
+ } else {
49
+ // Merge together
50
+ data = merge(data, fileData);
51
+ }
52
+ } catch (err) {
53
+ logError({
54
+ message: `Failed to parse "${path.join(getPathConfig().src, getPathConfig().data.src, fileName)}"`,
55
+ plugin: 'data',
56
+ });
57
+ }
58
+ } else {
59
+ logError({
60
+ message: `Data loader for files with "${extension}" extension is not defined in configuration data.loaders property`,
61
+ plugin: 'data',
62
+ });
63
+ }
64
+ }
65
+ }
66
+ });
67
+
68
+ return data;
69
+ },
70
+ {},
71
+ );
72
+
73
+ // Merge with env variables
74
+ return merge(data, envData.twig);
75
+ }
76
+
77
+ let cache = null;
78
+
79
+ export default function (options) {
80
+ const build = options && !!options.build;
81
+
82
+ return function () {
83
+ if (build) {
84
+ // Cache during full build
85
+ if (!cache) {
86
+ cache = getData();
87
+ }
88
+
89
+ return cache;
90
+ } else {
91
+ // Don't cache during watch build
92
+ cache = null;
93
+ return getData();
94
+ }
95
+ };
96
+ }
@@ -1,23 +1,26 @@
1
- /**
2
- * Enviromental variable loading configuration
3
- * Environment variables are loaded from .env files and remapped so that they can
4
- * be used in TWIG, SASS and JavaScript:
5
- * in TWIG `host` is accessible as `host`
6
- * in SCSS `host` is accessible as `map-get($env, host)`
7
- * in JS `host` is accessible as `process.env.host`
8
- */
9
-
10
- export const env = {
11
- // How env variable names should be remapped
12
- // Example:
13
- // map: { 'HOST': 'host', 'RECAPTCHA3_PUBLIC_KEY': 'recaptcha3_site_key' }
14
- map: {}
15
- };
16
-
17
- export const paths = {
18
- // Env files which to load relative to project folder
19
- env: [
20
- '../.env',
21
- '../.env.local',
22
- ],
23
- };
1
+ /**
2
+ * Enviromental variable loading configuration
3
+ * Environment variables are loaded from .env files and remapped so that they can
4
+ * be used in TWIG, SASS and JavaScript:
5
+ * in TWIG `host` is accessible as `host`
6
+ * in SCSS `host` is accessible as `map-get($env, host)`
7
+ * in JS `host` is accessible as `process.env.host`
8
+ */
9
+
10
+ export const env = {
11
+ // Write ASSET_VERSION to .env file to enable cache busting
12
+ writeAssetVersion: false,
13
+
14
+ // How env variable names should be remapped
15
+ // Example:
16
+ // map: { 'HOST': 'host', 'RECAPTCHA3_PUBLIC_KEY': 'recaptcha3_site_key' }
17
+ map: {}
18
+ };
19
+
20
+ export const paths = {
21
+ // Env files which to load relative to project folder
22
+ env: [
23
+ '../.env',
24
+ '../.env.local',
25
+ ],
26
+ };
@@ -1,81 +1,113 @@
1
- import dotenv from 'dotenv';
2
- import nanomemoize from 'nano-memoize';
3
- import { getPathConfig, getProjectPath } from '../../lib/get-path.js';
4
- import { getTaskConfig } from '../../lib/get-config.js';
5
-
6
- function escapeJSVariable(value) {
7
- if (value === 'true' || value === 'false' || value === true || value === false || !isNaN(value)) {
8
- return value;
9
- } else {
10
- // Convert to string
11
- return "'" + value.replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/\n/g, '\\n') + "'";
12
- }
13
- }
14
-
15
- function normalizeTwigVariable(value) {
16
- if (value === 'true') {
17
- return true;
18
- } else if (value === 'false') {
19
- return false;
20
- } else if (value !== '' && !isNaN(value)) {
21
- return parseFloat(value);
22
- } else {
23
- return value;
24
- }
25
- }
26
-
27
- /**
28
- * Load data from the .env files
29
- * @returns {object} List of environment variables
30
- */
31
- export const loadEnvData = nanomemoize.nanomemoize(function () {
32
- const envVariables = {};
33
- const envFiles = getPathConfig().env.map((path) => getProjectPath(path));
34
-
35
- dotenv.config({
36
- // dotenv file order is reversed, values in first file overwrite all other
37
- // file values
38
- path: envFiles.reverse(),
39
- processEnv: envVariables,
40
- quiet: true,
41
- });
42
-
43
- // Set assets version if it doesn't exist
44
- envVariables['ASSETS_VERSION'] = envVariables['ASSETS_VERSION'] || String(Math.floor(Date.now() / 1000));
45
-
46
- return envVariables;
47
- });
48
-
49
- /**
50
- * Returns environment variables mapped to the specified names
51
- * @returns {object} Mapped environment variables
52
- */
53
- export default function getEnvData() {
54
- const envVariables = loadEnvData();
55
- const twigVariables = {};
56
- const scssVariables = { env: { _tmp: 1 } }; // _tmp is used to avoid SCSS error if object is empty
57
- const jsVariables = {};
58
- const envOutVariables = {};
59
-
60
- // Remap property names
61
- const map = getTaskConfig('env', 'map');
62
-
63
- Object.keys(map).forEach((key) => {
64
- if (key in envVariables) {
65
- const value = envVariables[key];
66
- const camelCase = map[key];
67
- const kebabCase = map[key];
68
- twigVariables[camelCase] = normalizeTwigVariable(value);
69
- envOutVariables[camelCase] = value;
70
- jsVariables[`process.env.${camelCase}`] = escapeJSVariable(value);
71
- scssVariables.env[kebabCase] = value;
72
- }
73
- });
74
-
75
- return {
76
- twig: twigVariables,
77
- sass: scssVariables,
78
- js: jsVariables,
79
- env: envOutVariables,
80
- };
81
- }
1
+ import fs from 'node:fs';
2
+ import dotenv from 'dotenv';
3
+ import nanomemoize from 'nano-memoize';
4
+ import { getPathConfig, getProjectPath } from '../../lib/get-path.js';
5
+ import { getTaskConfig } from '../../lib/get-config.js';
6
+
7
+ function escapeJSVariable(value) {
8
+ if (value === 'true' || value === 'false' || value === true || value === false || !isNaN(value)) {
9
+ return value;
10
+ } else {
11
+ // Convert to string
12
+ return "'" + value.replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/\n/g, '\\n') + "'";
13
+ }
14
+ }
15
+
16
+ function normalizeTwigVariable(value) {
17
+ if (value === 'true') {
18
+ return true;
19
+ } else if (value === 'false') {
20
+ return false;
21
+ } else if (value !== '' && !isNaN(value)) {
22
+ return parseFloat(value);
23
+ } else {
24
+ return value;
25
+ }
26
+ }
27
+
28
+ /**
29
+ * Write asset version to the env file
30
+ * @param {string} assetVersion Asset version string
31
+ */
32
+ function writeEnvFileAssetVersion(assetVersion) {
33
+ const envFilePath = getTaskConfig('env', 'writeAssetVersion');
34
+ if (envFilePath) {
35
+ const envFile = getProjectPath(envFilePath);
36
+
37
+ try {
38
+ let envContent = fs.readFileSync(envFile, 'utf8');
39
+
40
+ // Replace ASSETS_VERSION if it exists
41
+ if (envContent.includes('ASSETS_VERSION=')) {
42
+ envContent = envContent.replace(/ASSETS_VERSION=.*/, `ASSETS_VERSION=${assetVersion}`);
43
+ } else {
44
+ envContent += `\nASSETS_VERSION=${assetVersion}`;
45
+ }
46
+
47
+ fs.writeFileSync(envFile, envContent);
48
+ } catch (error) {
49
+ console.error(`Error writing env file "${envFile}"`, error);
50
+ }
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Load data from the .env files
56
+ * @returns {object} List of environment variables
57
+ */
58
+ export const loadEnvData = nanomemoize.nanomemoize(function () {
59
+ const envVariables = {};
60
+ const envFiles = getPathConfig().env.map((path) => getProjectPath(path));
61
+
62
+ dotenv.config({
63
+ // dotenv file order is reversed, values in first file overwrite all other
64
+ // file values
65
+ path: envFiles.reverse(),
66
+ processEnv: envVariables,
67
+ quiet: true,
68
+ });
69
+
70
+ // Set assets version if it doesn't exist
71
+ if (!envVariables['ASSETS_VERSION'] || getTaskConfig('env', 'writeAssetVersion')) {
72
+ envVariables['ASSETS_VERSION'] = String(Math.floor(Date.now() / 1000));
73
+ writeEnvFileAssetVersion(envVariables['ASSETS_VERSION']);
74
+ }
75
+
76
+ return envVariables;
77
+ });
78
+
79
+ /**
80
+ * Returns environment variables mapped to the specified names
81
+ * @returns {object} Mapped environment variables
82
+ */
83
+ const getEnvData = nanomemoize.nanomemoize(function () {
84
+ const envVariables = loadEnvData();
85
+ const twigVariables = {};
86
+ const scssVariables = { env: { _tmp: 1 } }; // _tmp is used to avoid SCSS error if object is empty
87
+ const jsVariables = {};
88
+ const envOutVariables = {};
89
+
90
+ // Remap property names
91
+ const map = getTaskConfig('env', 'map');
92
+
93
+ Object.keys(map).forEach((key) => {
94
+ if (key in envVariables) {
95
+ const value = envVariables[key];
96
+ const camelCase = map[key];
97
+ const kebabCase = map[key];
98
+ twigVariables[camelCase] = normalizeTwigVariable(value);
99
+ envOutVariables[camelCase] = value;
100
+ jsVariables[`process.env.${camelCase}`] = escapeJSVariable(value);
101
+ scssVariables.env[kebabCase] = value;
102
+ }
103
+ });
104
+
105
+ return {
106
+ twig: twigVariables,
107
+ sass: scssVariables,
108
+ js: jsVariables,
109
+ env: envOutVariables,
110
+ };
111
+ });
112
+
113
+ export default getEnvData;
@@ -1,24 +1,24 @@
1
- import * as fontTask from './task.js';
2
-
3
- export const fonts = {
4
- // Glob list of files, which to ignore, relative to the font source folder
5
- // see https://gulpjs.com/docs/en/getting-started/explaining-globs/
6
- ignore: [],
7
-
8
- // Font file extensions
9
- extensions: ['woff2', 'woff', 'eot', 'ttf', 'svg', 'otf'],
10
- };
11
-
12
- export const tasks = {
13
- fonts: [fontTask],
14
- };
15
-
16
- /**
17
- * Paths relative to the global src and dest folders
18
- */
19
- export const paths = {
20
- fonts: {
21
- src: 'fonts',
22
- dest: 'assets/fonts',
23
- },
24
- };
1
+ import * as fontTask from './task.js';
2
+
3
+ export const fonts = {
4
+ // Glob list of files, which to ignore, relative to the font source folder
5
+ // see https://gulpjs.com/docs/en/getting-started/explaining-globs/
6
+ ignore: [],
7
+
8
+ // Font file extensions
9
+ extensions: ['woff2', 'woff', 'eot', 'ttf', 'svg', 'otf'],
10
+ };
11
+
12
+ export const tasks = {
13
+ fonts: [fontTask],
14
+ };
15
+
16
+ /**
17
+ * Paths relative to the global src and dest folders
18
+ */
19
+ export const paths = {
20
+ fonts: {
21
+ src: 'fonts',
22
+ dest: 'assets/fonts',
23
+ },
24
+ };