@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.
Files changed (102) hide show
  1. package/.prettierrc +11 -0
  2. package/README.md +2 -2
  3. package/bin/builder.js +17 -11
  4. package/eslint.config.js +39 -0
  5. package/gulpfile.js +63 -0
  6. package/init/default/config/config.js +18 -15
  7. package/init/default/src/html/data/global.js +1 -1
  8. package/init/default/src/javascripts/_entries.js +1 -1
  9. package/init/index.js +44 -37
  10. package/init/test/config/config.js +20 -16
  11. package/init/test/src/html/data/global.js +1 -1
  12. package/lib/camelize-file-name.js +1 -1
  13. package/lib/generate-gulp-tasks.js +12 -10
  14. package/lib/get-config.js +99 -52
  15. package/lib/get-file-names.js +3 -3
  16. package/lib/get-path.js +15 -22
  17. package/lib/globs-helper.js +22 -47
  18. package/lib/gulp/dynamic-task.js +1 -1
  19. package/lib/gulp/resolve-dynamic-task.js +1 -1
  20. package/lib/gulp/task-before-dest.js +2 -2
  21. package/lib/gulp/task-end.js +5 -5
  22. package/lib/gulp/task-start.js +3 -3
  23. package/lib/gulp/task-watch.js +10 -10
  24. package/lib/init/copy-folder.js +4 -4
  25. package/lib/init/folder-exists.js +2 -2
  26. package/lib/init/get-folder-list.js +3 -3
  27. package/lib/init/merge-package.js +8 -8
  28. package/lib/init/read-package.js +2 -2
  29. package/lib/log-error.js +3 -3
  30. package/lib/merge.js +3 -3
  31. package/lib/run-preprocess.js +2 -2
  32. package/lib/task-order.js +7 -13
  33. package/package.json +6 -4
  34. package/plugins/example/preprocess-config.js +1 -1
  35. package/plugins/example/task.js +13 -13
  36. package/plugins/example.js +8 -6
  37. package/plugins/sass-engine/preprocess-config.js +15 -19
  38. package/plugins/sass.js +5 -3
  39. package/plugins/twig/lodash-filters/filters.js +12 -10
  40. package/plugins/twig/lodash-filters.js +3 -3
  41. package/plugins/twig/symfony-filters/filters.js +18 -14
  42. package/plugins/twig/symfony-filters/preposition_nbsp.js +1 -1
  43. package/plugins/twig/symfony-filters.js +6 -6
  44. package/plugins/twig/symfony-functions/functions.js +2 -2
  45. package/plugins/twig/symfony-functions.js +6 -6
  46. package/plugins/twig-engine/preprocess-config.js +8 -8
  47. package/plugins/twig.js +11 -6
  48. package/tasks/browser-sync/config.js +9 -6
  49. package/tasks/browser-sync/preprocess-config.js +5 -7
  50. package/tasks/browser-sync/task.js +5 -5
  51. package/tasks/clean/config.js +8 -5
  52. package/tasks/clean/preprocess-config.js +5 -5
  53. package/tasks/clean/task.js +5 -5
  54. package/tasks/data/config.js +11 -13
  55. package/tasks/data/data-loader-js.js +11 -2
  56. package/tasks/data/data-loader-json.js +3 -3
  57. package/tasks/data/get-data.js +55 -52
  58. package/tasks/env/config.js +2 -2
  59. package/tasks/env/get-env.js +34 -19
  60. package/tasks/fonts/config.js +9 -10
  61. package/tasks/fonts/task.js +27 -27
  62. package/tasks/global/config.js +1 -1
  63. package/tasks/html/config.js +13 -15
  64. package/tasks/html/task.js +55 -54
  65. package/tasks/icons/config.js +17 -22
  66. package/tasks/icons/preprocess-config.js +4 -4
  67. package/tasks/icons/task.js +34 -35
  68. package/tasks/images/config.js +11 -14
  69. package/tasks/images/task.js +26 -26
  70. package/tasks/javascripts/config.js +12 -14
  71. package/tasks/javascripts/preprocess-config.js +45 -32
  72. package/tasks/javascripts/task.js +40 -43
  73. package/tasks/sitemap/config.js +12 -13
  74. package/tasks/sitemap/preprocess-config.js +2 -2
  75. package/tasks/sitemap/task.js +44 -38
  76. package/tasks/sizereport/config.js +5 -3
  77. package/tasks/sizereport/task.js +8 -8
  78. package/tasks/static/config.js +12 -15
  79. package/tasks/static/task.js +27 -28
  80. package/tasks/stylesheets/config.js +16 -19
  81. package/tasks/stylesheets/preprocess-config.js +5 -5
  82. package/tasks/stylesheets/task.js +28 -28
  83. package/tests/build/build.test.js +23 -22
  84. package/tests/camelize-file-name.test.js +1 -1
  85. package/tests/generate-gulp-tasks.test.js +11 -5
  86. package/tests/glob-helper.test.js +1 -1
  87. package/tests/merge.test.js +1 -1
  88. package/tests/preposition_nbsp.test.js +7 -6
  89. package/tests/run-preprocess.test.js +2 -1
  90. package/tests/sass-stringify.test.js +1 -1
  91. package/tests/sitemap.test.js +7 -6
  92. package/vendor/gulp-rolldown/index.js +24 -56
  93. package/vendor/gulp-rolldown/plugin-raw.js +17 -0
  94. package/vendor/gulp-rolldown/plugin-virtual-entry.js +30 -0
  95. package/vendor/gulp-sass/README.md +10 -19
  96. package/vendor/gulp-sass/index.js +129 -135
  97. package/vendor/gulp-sass/package.json +1 -0
  98. package/vendor/gulp-sass/sass-stringify.js +1 -1
  99. package/vendor/gulp-twig/index.js +32 -27
  100. package/vendor/gulp-twig/package.json +1 -0
  101. package/.eslintrc.js +0 -35
  102. 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
- exports.browserSync = {
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
- exports.preprocess = {
17
+ export const preprocess = {
15
18
  browserSync: [
16
- require('./preprocess-config'),
19
+ preprocessBrowserSyncConfig,
17
20
  ]
18
21
  };
19
22
 
20
- exports.tasks = {
23
+ export const tasks = {
21
24
  browserSync: [
22
- require('./task'),
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
- exports.paths = {
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
- const map = require('lodash/map');
2
- const getPaths = require('./../../lib/get-path');
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
- module.exports = function preprocessBrowserSyncConfig (config = {}, fullConfig) {
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 = getPaths.getProjectPath(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 = getPaths.getDestPath('browserSync')
27
+ config.server.baseDir = getDestPath('browserSync')
30
28
  }
31
29
  }
32
30
 
@@ -1,9 +1,9 @@
1
- const bs = require('browser-sync');
2
- const getConfig = require('./../../lib/get-config');
1
+ import bs from 'browser-sync';
2
+ import { getTaskConfig } from './../../lib/get-config.js';
3
3
 
4
- exports.watch = function browserSync (callback) {
5
- bs.init(getConfig.getTaskConfig('browserSync'));
4
+ export const watch = function browserSync(callback) {
5
+ bs.init(getTaskConfig('browserSync'));
6
6
  };
7
7
 
8
8
  // Execute as first task
9
- exports.watch.order = -2;
9
+ watch.order = -2;
@@ -1,17 +1,20 @@
1
- exports.clean = {
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
- exports.preprocess = {
10
+ export const preprocess = {
8
11
  clean: [
9
- require('./preprocess-config'),
12
+ preprocessCleanConfig,
10
13
  ]
11
14
  };
12
15
 
13
- exports.tasks = {
16
+ export const tasks = {
14
17
  clean: [
15
- require('./task'),
18
+ taskClean,
16
19
  ]
17
20
  };
@@ -1,5 +1,5 @@
1
- const getPaths = require('./../../lib/get-path');
2
- const globs = require('./../../lib/globs-helper');
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
- module.exports = function preprocessCleanConfig (config = {}, fullConfig) {
11
+ export default function preprocessCleanConfig(config = {}, fullConfig) {
12
12
  if (!config.patterns || !config.patterns.length) {
13
- config.patterns = globs.paths(getPaths.getDestPath()).generate();
13
+ config.patterns = globs.paths(getDestPath()).generate();
14
14
  } else {
15
- config.patterns = globs.paths(getPaths.getDestPath()).paths(config.patterns).generate();
15
+ config.patterns = globs.paths(getDestPath()).paths(config.patterns).generate();
16
16
  }
17
17
 
18
18
  return config;
@@ -1,7 +1,7 @@
1
- const del = require('del')
2
- const getConfig = require('./../../lib/get-config');
1
+ import del from 'del';
2
+ import { getTaskConfig } from '../../lib/get-config.js';
3
3
 
4
- exports.beforeBuild = function clean (callback) {
5
- const patterns = getConfig.getTaskConfig('clean', 'patterns');
4
+ export function beforeBuild(callback) {
5
+ const patterns = getTaskConfig('clean', 'patterns');
6
6
  return del(patterns, { force: true });
7
- };
7
+ }
@@ -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
- exports.data = {
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: require('./data-loader-js'),
15
- json: require('./data-loader-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
- exports.paths = {
30
+ export const paths = {
33
31
  data: {
34
- 'src': 'html/data',
35
- }
32
+ src: 'html/data',
33
+ },
36
34
  };
@@ -1,5 +1,14 @@
1
- module.exports = function dataLoaderJS (fileName) {
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
- return require(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
+ }
5
14
  };
@@ -1,5 +1,5 @@
1
- const fs = require('fs');
1
+ import fs from 'fs';
2
2
 
3
- module.exports = function dataLoaderJSON (fileName) {
3
+ export default function dataLoaderJSON(fileName) {
4
4
  return JSON.parse(fs.readFileSync(fileName, 'utf8'));
5
- };
5
+ }
@@ -1,79 +1,82 @@
1
- const path = require('path');
2
- const reduce = require('lodash/reduce');
3
- const micromatch = require('micromatch'); // gulp dependency
1
+ import path from 'path';
2
+ import reduce from 'lodash/reduce.js';
3
+ import micromatch from 'micromatch'; // gulp dependency
4
4
 
5
- const merge = require('../../lib/merge');
6
- const getPaths = require('../../lib/get-path');
7
- const getConfig = require('../../lib/get-config');
8
- const logError = require('../../lib/log-error');
9
- const getFileNamesSync = require('../../lib/get-file-names');
10
- const camelizeFileName = require('../../lib/camelize-file-name');
11
- const getEnvData = require('../env/get-env');
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 = getPaths.getSourcePaths('data');
15
- const extensions = getConfig.getTaskConfig('data', 'extensions');
16
- const loaders = getConfig.getTaskConfig('data', 'loaders');
17
- const ignore = getConfig.getTaskConfig('data', 'ignore');
18
- const group = getConfig.getTaskConfig('data', 'groupByFileName');
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(folders, (data, folder) => {
26
- getFileNamesSync(folder).forEach(fileName => {
27
- // Ignore files matching 'ignore' list
28
- if (ignore.length && micromatch.isMatch(fileName, ignore)) {
29
- return;
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
- // Ignore files starting with underscore
33
- if (fileName[0] !== '_') {
34
- const extension = fileName.split('.').pop();
34
+ // Ignore files starting with underscore
35
+ if (fileName[0] !== '_') {
36
+ const extension = fileName.split('.').pop();
35
37
 
36
- if (extension && extensions.indexOf(extension) !== -1) {
37
- if (extension in loaders) {
38
- try {
39
- const fullFilePath = path.resolve(folder, fileName);
40
- const fileData = loaders[extension](fullFilePath);
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
- if (group) {
43
- // Group data
44
- const name = camelizeFileName(fileName);
45
- data = merge(data, {[name]: fileData});
46
- } else {
47
- // Merge together
48
- data = merge(data, fileData);
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
- } catch (err) {
58
+ } else {
51
59
  logError({
52
- 'message': `Failed to parse "${ path.join(getPaths.getPathConfig().src, getPaths.getPathConfig().data.src, fileName) }"`,
53
- 'plugin': 'data'
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
- return data;
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
- module.exports = function (options) {
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
  }
@@ -7,14 +7,14 @@
7
7
  * in JS `host` is accessible as `process.env.host`
8
8
  */
9
9
 
10
- exports.env = {
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
- exports.paths = {
17
+ export const paths = {
18
18
  // Env files which to load relative to project folder
19
19
  env: [
20
20
  '../.env',
@@ -1,17 +1,18 @@
1
- const paths = require('../../lib/get-path');
2
- const dotenv = require('dotenv');
3
- const getConfig = require('../../lib/get-config');
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 (value) {
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, '\\\'').replace(/\n/g, '\\n') + "'";
11
+ return "'" + value.replace(/\\/g, '\\\\').replace(/'/g, "\\'").replace(/\n/g, '\\n') + "'";
11
12
  }
12
13
  }
13
14
 
14
- function normalizeTwigVariable (value) {
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
- function getEnvData () {
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 twigVariables = {};
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 = getConfig.getTaskConfig('env', '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.${ camelCase }`] = escapeJSVariable(value);
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;
@@ -1,4 +1,6 @@
1
- exports.fonts = {
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
- exports.tasks = {
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
- exports.paths = {
19
+ export const paths = {
21
20
  fonts: {
22
- 'src': 'fonts',
23
- 'dest': 'assets/fonts',
24
- }
21
+ src: 'fonts',
22
+ dest: 'assets/fonts',
23
+ },
25
24
  };
@@ -1,47 +1,47 @@
1
- const gulp = require('gulp');
2
- const { nanomemoize } = require('nano-memoize');
1
+ import gulp from 'gulp';
2
+ import nanomemoize from 'nano-memoize';
3
3
 
4
- const globs = require('./../../lib/globs-helper');
5
- const getPaths = require('./../../lib/get-path');
6
- const getConfig = require('./../../lib/get-config');
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
- const taskStart = require('../../lib/gulp/task-start');
9
- const taskEnd = require('../../lib/gulp/task-end');
10
- const taskBeforeDest = require('../../lib/gulp/task-before-dest');
11
- const taskWatch = require('../../lib/gulp/task-watch');
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 = getPaths.getSourcePaths('fonts');
15
- const extensions = getConfig.getTaskConfig('fonts', 'extensions');
16
- const ignore = getConfig.getTaskConfig('fonts', '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(), // List of files which to 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
- function fonts () {
30
- return gulp
31
- .src(getGlobPaths(), { since: gulp.lastRun(fonts) })
32
- .pipe(taskStart())
34
+ .pipe(taskBeforeDest())
35
+ .pipe(gulp.dest(getDestPath('fonts')))
33
36
 
34
- .pipe(taskBeforeDest())
35
- .pipe(gulp.dest(getPaths.getDestPath('fonts')))
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
- exports.build = fonts;
47
- exports.watch = fontsWatch;
46
+ export const build = fonts;
47
+ export const watch = fontsWatch;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Paths relative to the project path from where `npm run ...` command is run
3
3
  */
4
- exports.paths = {
4
+ export const paths = {
5
5
  src: './src',
6
6
  dest: './public',
7
7
  };
@@ -1,4 +1,6 @@
1
- exports.html = {
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
- exports.tasks = {
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
- exports.paths = {
37
+ export const paths = {
40
38
  html: {
41
- 'src': 'html',
42
- 'dest': '',
43
- }
39
+ src: 'html',
40
+ dest: '',
41
+ },
44
42
  };