@videinfra/static-website-builder 2.0.0-beta.2 → 2.0.0-beta.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.
- package/.prettierrc +11 -0
- package/README.md +2 -2
- package/bin/builder.js +17 -11
- package/eslint.config.js +39 -0
- package/gulpfile.js +63 -0
- package/init/default/config/config.js +18 -15
- package/init/default/src/html/data/global.js +1 -1
- package/init/default/src/javascripts/_entries.js +1 -1
- package/init/index.js +44 -37
- package/init/test/config/config.js +20 -16
- package/init/test/src/html/data/global.js +1 -1
- package/lib/camelize-file-name.js +1 -1
- package/lib/generate-gulp-tasks.js +12 -10
- package/lib/get-config.js +99 -52
- package/lib/get-file-names.js +3 -3
- package/lib/get-path.js +15 -22
- package/lib/globs-helper.js +22 -47
- package/lib/gulp/dynamic-task.js +1 -1
- package/lib/gulp/resolve-dynamic-task.js +1 -1
- package/lib/gulp/task-before-dest.js +2 -2
- package/lib/gulp/task-end.js +5 -5
- package/lib/gulp/task-start.js +3 -3
- package/lib/gulp/task-watch.js +10 -10
- package/lib/init/copy-folder.js +4 -4
- package/lib/init/folder-exists.js +2 -2
- package/lib/init/get-folder-list.js +3 -3
- package/lib/init/merge-package.js +8 -8
- package/lib/init/read-package.js +2 -2
- package/lib/log-error.js +3 -3
- package/lib/merge.js +3 -3
- package/lib/run-preprocess.js +2 -2
- package/lib/task-order.js +7 -13
- package/package.json +6 -4
- package/plugins/example/preprocess-config.js +1 -1
- package/plugins/example/task.js +13 -13
- package/plugins/example.js +8 -6
- package/plugins/sass-engine/preprocess-config.js +15 -19
- package/plugins/sass.js +5 -3
- package/plugins/twig/lodash-filters/filters.js +12 -10
- package/plugins/twig/lodash-filters.js +3 -3
- package/plugins/twig/symfony-filters/filters.js +18 -14
- package/plugins/twig/symfony-filters/preposition_nbsp.js +1 -1
- package/plugins/twig/symfony-filters.js +6 -6
- package/plugins/twig/symfony-functions/functions.js +2 -2
- package/plugins/twig/symfony-functions.js +6 -6
- package/plugins/twig-engine/preprocess-config.js +8 -8
- package/plugins/twig.js +11 -6
- package/tasks/browser-sync/config.js +9 -6
- package/tasks/browser-sync/preprocess-config.js +5 -7
- package/tasks/browser-sync/task.js +5 -5
- package/tasks/clean/config.js +8 -5
- package/tasks/clean/preprocess-config.js +5 -5
- package/tasks/clean/task.js +5 -5
- package/tasks/data/config.js +11 -13
- package/tasks/data/data-loader-js.js +11 -2
- package/tasks/data/data-loader-json.js +3 -3
- package/tasks/data/get-data.js +55 -52
- package/tasks/env/config.js +2 -2
- package/tasks/env/get-env.js +34 -19
- package/tasks/fonts/config.js +9 -10
- package/tasks/fonts/task.js +27 -27
- package/tasks/global/config.js +1 -1
- package/tasks/html/config.js +13 -15
- package/tasks/html/task.js +55 -54
- package/tasks/icons/config.js +17 -22
- package/tasks/icons/preprocess-config.js +4 -4
- package/tasks/icons/task.js +34 -35
- package/tasks/images/config.js +11 -14
- package/tasks/images/task.js +26 -26
- package/tasks/javascripts/config.js +12 -14
- package/tasks/javascripts/preprocess-config.js +45 -32
- package/tasks/javascripts/task.js +40 -43
- package/tasks/sitemap/config.js +12 -13
- package/tasks/sitemap/preprocess-config.js +2 -2
- package/tasks/sitemap/task.js +44 -38
- package/tasks/sizereport/config.js +5 -3
- package/tasks/sizereport/task.js +8 -8
- package/tasks/static/config.js +12 -15
- package/tasks/static/task.js +27 -28
- package/tasks/stylesheets/config.js +16 -19
- package/tasks/stylesheets/preprocess-config.js +5 -5
- package/tasks/stylesheets/task.js +28 -28
- package/tests/build/build.test.js +23 -22
- package/tests/camelize-file-name.test.js +1 -1
- package/tests/generate-gulp-tasks.test.js +11 -5
- package/tests/glob-helper.test.js +1 -1
- package/tests/merge.test.js +1 -1
- package/tests/preposition_nbsp.test.js +7 -6
- package/tests/run-preprocess.test.js +2 -1
- package/tests/sass-stringify.test.js +1 -1
- package/tests/sitemap.test.js +7 -6
- package/vendor/gulp-rolldown/index.js +24 -56
- package/vendor/gulp-rolldown/plugin-raw.js +17 -0
- package/vendor/gulp-rolldown/plugin-virtual-entry.js +30 -0
- package/vendor/gulp-sass/README.md +10 -19
- package/vendor/gulp-sass/index.js +129 -135
- package/vendor/gulp-sass/package.json +1 -0
- package/vendor/gulp-sass/sass-stringify.js +1 -1
- package/vendor/gulp-twig/index.js +32 -27
- package/vendor/gulp-twig/package.json +1 -0
- package/.eslintrc.js +0 -35
- package/gulpfile.js/index.js +0 -32
|
@@ -1,7 +1,10 @@
|
|
|
1
|
+
import * as preprocessBrowserSyncConfig from './preprocess-config.js';
|
|
2
|
+
import * as taskBrowserSync from './task.js';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Browsersync DEV server settings
|
|
3
6
|
*/
|
|
4
|
-
|
|
7
|
+
export const browserSync = {
|
|
5
8
|
// Production only settings, overwrites default settings
|
|
6
9
|
production: false,
|
|
7
10
|
|
|
@@ -11,15 +14,15 @@ exports.browserSync = {
|
|
|
11
14
|
},
|
|
12
15
|
};
|
|
13
16
|
|
|
14
|
-
|
|
17
|
+
export const preprocess = {
|
|
15
18
|
browserSync: [
|
|
16
|
-
|
|
19
|
+
preprocessBrowserSyncConfig,
|
|
17
20
|
]
|
|
18
21
|
};
|
|
19
22
|
|
|
20
|
-
|
|
23
|
+
export const tasks = {
|
|
21
24
|
browserSync: [
|
|
22
|
-
|
|
25
|
+
taskBrowserSync,
|
|
23
26
|
]
|
|
24
27
|
};
|
|
25
28
|
|
|
@@ -27,7 +30,7 @@ exports.tasks = {
|
|
|
27
30
|
/**
|
|
28
31
|
* Paths relative to the global src and dest folders
|
|
29
32
|
*/
|
|
30
|
-
|
|
33
|
+
export const paths = {
|
|
31
34
|
browserSync: {
|
|
32
35
|
// Server root directory, relative to the project
|
|
33
36
|
// If not set then global dest folder
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
const globs = require('./../../lib/globs-helper');
|
|
4
|
-
const isPlainObject = require('lodash/isPlainObject');
|
|
1
|
+
import { getProjectPath, getDestPath } from './../../lib/get-path.js';
|
|
2
|
+
import isPlainObject from 'lodash/isPlainObject.js';
|
|
5
3
|
|
|
6
4
|
/**
|
|
7
5
|
* Modify configuration
|
|
@@ -10,7 +8,7 @@ const isPlainObject = require('lodash/isPlainObject');
|
|
|
10
8
|
* @param {object} fullConfig Full configuration
|
|
11
9
|
* @returns {object} Transformed browserSync configuration
|
|
12
10
|
*/
|
|
13
|
-
|
|
11
|
+
export default function preprocessBrowserSyncConfig (config = {}, fullConfig) {
|
|
14
12
|
// If server is disabled then disable whole browserSync
|
|
15
13
|
// If HTML is not being rendered, then browserSync has no use
|
|
16
14
|
if (config.server === false || fullConfig.html === false) return false;
|
|
@@ -23,10 +21,10 @@ module.exports = function preprocessBrowserSyncConfig (config = {}, fullConfig)
|
|
|
23
21
|
if (config.server) {
|
|
24
22
|
if (config.server.baseDir) {
|
|
25
23
|
// Relative to the project
|
|
26
|
-
config.server.baseDir =
|
|
24
|
+
config.server.baseDir = getProjectPath(config.server.baseDir);
|
|
27
25
|
} else {
|
|
28
26
|
// Set to output folder from path-config.js
|
|
29
|
-
config.server.baseDir =
|
|
27
|
+
config.server.baseDir = getDestPath('browserSync')
|
|
30
28
|
}
|
|
31
29
|
}
|
|
32
30
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import bs from 'browser-sync';
|
|
2
|
+
import { getTaskConfig } from './../../lib/get-config.js';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
bs.init(
|
|
4
|
+
export const watch = function browserSync(callback) {
|
|
5
|
+
bs.init(getTaskConfig('browserSync'));
|
|
6
6
|
};
|
|
7
7
|
|
|
8
8
|
// Execute as first task
|
|
9
|
-
|
|
9
|
+
watch.order = -2;
|
package/tasks/clean/config.js
CHANGED
|
@@ -1,17 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import * as preprocessCleanConfig from './preprocess-config.js';
|
|
2
|
+
import * as taskClean from './task.js';
|
|
3
|
+
|
|
4
|
+
export const clean = {
|
|
2
5
|
// Patterns, relative to the destination folder, see https://gulpjs.com/docs/en/getting-started/explaining-globs/
|
|
3
6
|
// patterns: ['assets/**', 'temp-folder']
|
|
4
7
|
patterns: [],
|
|
5
8
|
};
|
|
6
9
|
|
|
7
|
-
|
|
10
|
+
export const preprocess = {
|
|
8
11
|
clean: [
|
|
9
|
-
|
|
12
|
+
preprocessCleanConfig,
|
|
10
13
|
]
|
|
11
14
|
};
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
export const tasks = {
|
|
14
17
|
clean: [
|
|
15
|
-
|
|
18
|
+
taskClean,
|
|
16
19
|
]
|
|
17
20
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import { getDestPath } from './../../lib/get-path.js';
|
|
2
|
+
import globs from './../../lib/globs-helper.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Modify configuration
|
|
@@ -8,11 +8,11 @@ const globs = require('./../../lib/globs-helper');
|
|
|
8
8
|
* @param {object} fullConfig Full configuration
|
|
9
9
|
* @returns {object} Transformed clean configuration
|
|
10
10
|
*/
|
|
11
|
-
|
|
11
|
+
export default function preprocessCleanConfig(config = {}, fullConfig) {
|
|
12
12
|
if (!config.patterns || !config.patterns.length) {
|
|
13
|
-
config.patterns = globs.paths(
|
|
13
|
+
config.patterns = globs.paths(getDestPath()).generate();
|
|
14
14
|
} else {
|
|
15
|
-
config.patterns = globs.paths(
|
|
15
|
+
config.patterns = globs.paths(getDestPath()).paths(config.patterns).generate();
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
return config;
|
package/tasks/clean/task.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import del from 'del';
|
|
2
|
+
import { getTaskConfig } from '../../lib/get-config.js';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
const patterns =
|
|
4
|
+
export function beforeBuild(callback) {
|
|
5
|
+
const patterns = getTaskConfig('clean', 'patterns');
|
|
6
6
|
return del(patterns, { force: true });
|
|
7
|
-
}
|
|
7
|
+
}
|
package/tasks/data/config.js
CHANGED
|
@@ -1,36 +1,34 @@
|
|
|
1
|
+
import dataLoaderJs from './data-loader-js.js';
|
|
2
|
+
import dataLoaderJson from './data-loader-json.js';
|
|
3
|
+
|
|
1
4
|
/**
|
|
2
5
|
* Data loading for HTML task
|
|
3
6
|
* This task doesn't have actual task, instead it's used by 'html' task
|
|
4
7
|
*/
|
|
5
8
|
|
|
6
|
-
|
|
7
|
-
extensions: [
|
|
8
|
-
'js',
|
|
9
|
-
'json'
|
|
10
|
-
],
|
|
9
|
+
export const data = {
|
|
10
|
+
extensions: ['js', 'json'],
|
|
11
11
|
|
|
12
12
|
// Data loaders for extensions, allows to add custom loaders
|
|
13
13
|
loaders: {
|
|
14
|
-
js:
|
|
15
|
-
json:
|
|
14
|
+
js: dataLoaderJs,
|
|
15
|
+
json: dataLoaderJson,
|
|
16
16
|
},
|
|
17
17
|
|
|
18
18
|
// Glob list of files, which to ignore, relative to the data source folder
|
|
19
19
|
// see https://gulpjs.com/docs/en/getting-started/explaining-globs/
|
|
20
|
-
ignore: [
|
|
21
|
-
],
|
|
20
|
+
ignore: [],
|
|
22
21
|
|
|
23
22
|
// Group data by filename (without extension + cammelCase)
|
|
24
23
|
// eg, person-names.js -> {'personNames': ...}
|
|
25
24
|
groupByFileName: false,
|
|
26
25
|
};
|
|
27
26
|
|
|
28
|
-
|
|
29
27
|
/**
|
|
30
28
|
* Paths relative to the global src and dest folders
|
|
31
29
|
*/
|
|
32
|
-
|
|
30
|
+
export const paths = {
|
|
33
31
|
data: {
|
|
34
|
-
|
|
35
|
-
}
|
|
32
|
+
src: 'html/data',
|
|
33
|
+
},
|
|
36
34
|
};
|
|
@@ -1,5 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
import { createRequire } from 'node:module';
|
|
2
|
+
const require = createRequire(import.meta.url);
|
|
3
|
+
|
|
4
|
+
export default function dataLoaderJS (fileName) {
|
|
2
5
|
// Re-load script each time this function is called
|
|
3
6
|
delete require.cache[require.resolve(fileName)];
|
|
4
|
-
|
|
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
|
+
}
|
|
5
14
|
};
|
package/tasks/data/get-data.js
CHANGED
|
@@ -1,79 +1,82 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import path from 'path';
|
|
2
|
+
import reduce from 'lodash/reduce.js';
|
|
3
|
+
import micromatch from 'micromatch'; // gulp dependency
|
|
4
4
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
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
12
|
|
|
13
|
-
function getData
|
|
14
|
-
const folders =
|
|
15
|
-
const extensions =
|
|
16
|
-
const loaders =
|
|
17
|
-
const ignore =
|
|
18
|
-
const group =
|
|
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
19
|
const envData = getEnvData();
|
|
20
20
|
|
|
21
21
|
// Merge into process.env before loading data because these may be used
|
|
22
22
|
// in data
|
|
23
23
|
merge(process.env, envData.env);
|
|
24
24
|
|
|
25
|
-
const data = reduce(
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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
|
+
}
|
|
31
33
|
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
// Ignore files starting with underscore
|
|
35
|
+
if (fileName[0] !== '_') {
|
|
36
|
+
const extension = fileName.split('.').pop();
|
|
35
37
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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);
|
|
41
43
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
+
});
|
|
49
57
|
}
|
|
50
|
-
}
|
|
58
|
+
} else {
|
|
51
59
|
logError({
|
|
52
|
-
|
|
53
|
-
|
|
60
|
+
message: `Data loader for files with "${extension}" extension is not defined in configuration data.loaders property`,
|
|
61
|
+
plugin: 'data',
|
|
54
62
|
});
|
|
55
63
|
}
|
|
56
|
-
} else {
|
|
57
|
-
logError({
|
|
58
|
-
'message': `Data loader for files with "${ extension }" extension is not defined in configuration data.loaders property`,
|
|
59
|
-
'plugin': 'data'
|
|
60
|
-
});
|
|
61
64
|
}
|
|
62
65
|
}
|
|
63
|
-
}
|
|
64
|
-
});
|
|
66
|
+
});
|
|
65
67
|
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
return data;
|
|
69
|
+
},
|
|
70
|
+
{},
|
|
71
|
+
);
|
|
68
72
|
|
|
69
73
|
// Merge with env variables
|
|
70
74
|
return merge(data, envData.twig);
|
|
71
75
|
}
|
|
72
76
|
|
|
73
|
-
|
|
74
77
|
let cache = null;
|
|
75
78
|
|
|
76
|
-
|
|
79
|
+
export default function (options) {
|
|
77
80
|
const build = options && !!options.build;
|
|
78
81
|
|
|
79
82
|
return function () {
|
|
@@ -89,5 +92,5 @@ module.exports = function (options) {
|
|
|
89
92
|
cache = null;
|
|
90
93
|
return getData();
|
|
91
94
|
}
|
|
92
|
-
}
|
|
95
|
+
};
|
|
93
96
|
}
|
package/tasks/env/config.js
CHANGED
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
* in JS `host` is accessible as `process.env.host`
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
export const env = {
|
|
11
11
|
// How env variable names should be remapped
|
|
12
12
|
// Example:
|
|
13
13
|
// map: { 'HOST': 'host', 'RECAPTCHA3_PUBLIC_KEY': 'recaptcha3_site_key' }
|
|
14
14
|
map: {}
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
|
|
17
|
+
export const paths = {
|
|
18
18
|
// Env files which to load relative to project folder
|
|
19
19
|
env: [
|
|
20
20
|
'../.env',
|
package/tasks/env/get-env.js
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
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';
|
|
4
5
|
|
|
5
|
-
function escapeJSVariable
|
|
6
|
+
function escapeJSVariable(value) {
|
|
6
7
|
if (value === 'true' || value === 'false' || value === true || value === false || !isNaN(value)) {
|
|
7
8
|
return value;
|
|
8
9
|
} else {
|
|
9
10
|
// Convert to string
|
|
10
|
-
return "'" + value.replace(/\\/g, '\\\\').replace(/'/g, '
|
|
11
|
+
return "'" + value.replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/\n/g, '\\n') + "'";
|
|
11
12
|
}
|
|
12
13
|
}
|
|
13
14
|
|
|
14
|
-
function normalizeTwigVariable
|
|
15
|
+
function normalizeTwigVariable(value) {
|
|
15
16
|
if (value === 'true') {
|
|
16
17
|
return true;
|
|
17
18
|
} else if (value === 'false') {
|
|
@@ -23,14 +24,13 @@ function normalizeTwigVariable (value) {
|
|
|
23
24
|
}
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
|
|
27
|
+
/**
|
|
28
|
+
* Load data from the .env files
|
|
29
|
+
* @returns {object} List of environment variables
|
|
30
|
+
*/
|
|
31
|
+
export const loadEnvData = nanomemoize.nanomemoize(function () {
|
|
27
32
|
const envVariables = {};
|
|
28
|
-
const
|
|
29
|
-
const scssVariables = { env: { _tmp: 1 } }; // _tmp is used to avoid SCSS error if object is empty
|
|
30
|
-
const jsVariables = {};
|
|
31
|
-
const envOutVariables = {};
|
|
32
|
-
|
|
33
|
-
const envFiles = paths.getPathConfig().env.map((path) => paths.getProjectPath(path));
|
|
33
|
+
const envFiles = getPathConfig().env.map((path) => getProjectPath(path));
|
|
34
34
|
|
|
35
35
|
dotenv.config({
|
|
36
36
|
// dotenv file order is reversed, values in first file overwrite all other
|
|
@@ -40,17 +40,34 @@ function getEnvData () {
|
|
|
40
40
|
quiet: true,
|
|
41
41
|
});
|
|
42
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
|
+
|
|
43
60
|
// Remap property names
|
|
44
|
-
const map =
|
|
61
|
+
const map = getTaskConfig('env', 'map');
|
|
45
62
|
|
|
46
|
-
Object.keys(map).forEach(key => {
|
|
63
|
+
Object.keys(map).forEach((key) => {
|
|
47
64
|
if (key in envVariables) {
|
|
48
65
|
const value = envVariables[key];
|
|
49
66
|
const camelCase = map[key];
|
|
50
67
|
const kebabCase = map[key];
|
|
51
68
|
twigVariables[camelCase] = normalizeTwigVariable(value);
|
|
52
69
|
envOutVariables[camelCase] = value;
|
|
53
|
-
jsVariables[`process.env.${
|
|
70
|
+
jsVariables[`process.env.${camelCase}`] = escapeJSVariable(value);
|
|
54
71
|
scssVariables.env[kebabCase] = value;
|
|
55
72
|
}
|
|
56
73
|
});
|
|
@@ -60,7 +77,5 @@ function getEnvData () {
|
|
|
60
77
|
sass: scssVariables,
|
|
61
78
|
js: jsVariables,
|
|
62
79
|
env: envOutVariables,
|
|
63
|
-
}
|
|
80
|
+
};
|
|
64
81
|
}
|
|
65
|
-
|
|
66
|
-
module.exports = getEnvData;
|
package/tasks/fonts/config.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import * as fontTask from './task.js';
|
|
2
|
+
|
|
3
|
+
export const fonts = {
|
|
2
4
|
// Glob list of files, which to ignore, relative to the font source folder
|
|
3
5
|
// see https://gulpjs.com/docs/en/getting-started/explaining-globs/
|
|
4
6
|
ignore: [],
|
|
@@ -7,19 +9,16 @@ exports.fonts = {
|
|
|
7
9
|
extensions: ['woff2', 'woff', 'eot', 'ttf', 'svg', 'otf'],
|
|
8
10
|
};
|
|
9
11
|
|
|
10
|
-
|
|
11
|
-
fonts: [
|
|
12
|
-
require('./task'),
|
|
13
|
-
]
|
|
12
|
+
export const tasks = {
|
|
13
|
+
fonts: [fontTask],
|
|
14
14
|
};
|
|
15
15
|
|
|
16
|
-
|
|
17
16
|
/**
|
|
18
17
|
* Paths relative to the global src and dest folders
|
|
19
18
|
*/
|
|
20
|
-
|
|
19
|
+
export const paths = {
|
|
21
20
|
fonts: {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
}
|
|
21
|
+
src: 'fonts',
|
|
22
|
+
dest: 'assets/fonts',
|
|
23
|
+
},
|
|
25
24
|
};
|
package/tasks/fonts/task.js
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import gulp from 'gulp';
|
|
2
|
+
import nanomemoize from 'nano-memoize';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import globs from './../../lib/globs-helper.js';
|
|
5
|
+
import { getSourcePaths, getDestPath } from './../../lib/get-path.js';
|
|
6
|
+
import { getTaskConfig } from './../../lib/get-config.js';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
8
|
+
import taskStart from '../../lib/gulp/task-start.js';
|
|
9
|
+
import taskEnd from '../../lib/gulp/task-end.js';
|
|
10
|
+
import taskBeforeDest from '../../lib/gulp/task-before-dest.js';
|
|
11
|
+
import taskWatch from '../../lib/gulp/task-watch.js';
|
|
12
12
|
|
|
13
13
|
const getWatchGlobPaths = function (forChokidar = false) {
|
|
14
|
-
const sourcePaths =
|
|
15
|
-
const extensions =
|
|
16
|
-
const ignore =
|
|
14
|
+
const sourcePaths = getSourcePaths('fonts');
|
|
15
|
+
const extensions = getTaskConfig('fonts', 'extensions');
|
|
16
|
+
const ignore = getTaskConfig('fonts', 'ignore');
|
|
17
17
|
|
|
18
18
|
return globs.generate(
|
|
19
19
|
globs.paths(sourcePaths).filesWithExtensions(extensions), // Files to watch
|
|
20
|
-
globs.paths(sourcePaths).paths(ignore).ignore(),
|
|
20
|
+
globs.paths(sourcePaths).paths(ignore).ignore(), // List of files which to ignore
|
|
21
21
|
forChokidar,
|
|
22
22
|
);
|
|
23
23
|
};
|
|
24
|
-
const getGlobPaths = nanomemoize(function () {
|
|
24
|
+
const getGlobPaths = nanomemoize.nanomemoize(function () {
|
|
25
25
|
return getWatchGlobPaths(false);
|
|
26
26
|
});
|
|
27
27
|
|
|
28
|
+
function fonts() {
|
|
29
|
+
return (
|
|
30
|
+
gulp
|
|
31
|
+
.src(getGlobPaths(), { since: gulp.lastRun(fonts) })
|
|
32
|
+
.pipe(taskStart())
|
|
28
33
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
.src(getGlobPaths(), { since: gulp.lastRun(fonts) })
|
|
32
|
-
.pipe(taskStart())
|
|
34
|
+
.pipe(taskBeforeDest())
|
|
35
|
+
.pipe(gulp.dest(getDestPath('fonts')))
|
|
33
36
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
// Reload on change
|
|
38
|
-
.pipe(taskEnd());
|
|
37
|
+
// Reload on change
|
|
38
|
+
.pipe(taskEnd())
|
|
39
|
+
);
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
function fontsWatch
|
|
42
|
+
function fontsWatch() {
|
|
42
43
|
return taskWatch(getWatchGlobPaths(true), fonts);
|
|
43
44
|
}
|
|
44
45
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
exports.watch = fontsWatch;
|
|
46
|
+
export const build = fonts;
|
|
47
|
+
export const watch = fontsWatch;
|
package/tasks/global/config.js
CHANGED
package/tasks/html/config.js
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import * as htmlTask from './task.js';
|
|
2
|
+
|
|
3
|
+
export const html = {
|
|
2
4
|
// Engine is a function which returns a gulp pipe function, eg. sass()
|
|
3
5
|
// Intended to be used by plugins, not manually
|
|
4
6
|
engine: null,
|
|
@@ -8,37 +10,33 @@ exports.html = {
|
|
|
8
10
|
|
|
9
11
|
// Glob list of files, which to ignore, relative to the html source folder
|
|
10
12
|
// see https://gulpjs.com/docs/en/getting-started/explaining-globs/
|
|
11
|
-
ignore: [
|
|
12
|
-
],
|
|
13
|
+
ignore: [],
|
|
13
14
|
|
|
14
15
|
// Production only settings, overwrites default settings
|
|
15
16
|
production: {
|
|
16
17
|
// Enable HTML minification
|
|
17
18
|
htmlmin: {
|
|
18
|
-
collapseWhitespace: true
|
|
19
|
-
}
|
|
19
|
+
collapseWhitespace: true,
|
|
20
|
+
},
|
|
20
21
|
},
|
|
21
22
|
|
|
22
23
|
// Development only settings, overwrites default settings
|
|
23
24
|
development: {
|
|
24
25
|
// Disable HTML minification
|
|
25
|
-
htmlmin: false
|
|
26
|
+
htmlmin: false,
|
|
26
27
|
},
|
|
27
28
|
};
|
|
28
29
|
|
|
29
|
-
|
|
30
|
-
html: [
|
|
31
|
-
require('./task'),
|
|
32
|
-
]
|
|
30
|
+
export const tasks = {
|
|
31
|
+
html: [htmlTask],
|
|
33
32
|
};
|
|
34
33
|
|
|
35
|
-
|
|
36
34
|
/**
|
|
37
35
|
* Paths relative to the global src and dest folders
|
|
38
36
|
*/
|
|
39
|
-
|
|
37
|
+
export const paths = {
|
|
40
38
|
html: {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
39
|
+
src: 'html',
|
|
40
|
+
dest: '',
|
|
41
|
+
},
|
|
44
42
|
};
|