@videinfra/static-website-builder 2.0.0-beta.2 → 2.0.0-beta.3
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/.eslintrc.js +1 -1
- package/.prettierrc +11 -0
- package/README.md +2 -2
- package/bin/builder.js +17 -11
- 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 +11 -10
- 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 +13 -13
- 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 +30 -30
- 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 +27 -29
- 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/gulpfile.js/index.js +0 -32
package/lib/init/read-package.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import fsPromise from 'fs/promises';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default function mergePackage (fileName, defaultValue = null) {
|
|
4
4
|
return fsPromise.readFile(fileName, {'encoding': 'utf8'}).then((data) => {
|
|
5
5
|
try {
|
|
6
6
|
return JSON.parse(data);
|
package/lib/log-error.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
|
|
1
|
+
import chalk from 'chalk';
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
export default function (error, failOnError = false) {
|
|
4
4
|
const message = String(error.messageFormatted || error.message);
|
|
5
5
|
const messageTrimmed = message.length > 4096 ? message.slice(0, 512) + '...' : message;
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ module.exports = function (error, failOnError = false) {
|
|
|
8
8
|
|
|
9
9
|
if (failOnError) {
|
|
10
10
|
throw error;
|
|
11
|
-
} else if (typeof this.emit === 'function') {
|
|
11
|
+
} else if (this && typeof this.emit === 'function') {
|
|
12
12
|
// Emit the end event, to properly end the task
|
|
13
13
|
this.emit('end');
|
|
14
14
|
}
|
package/lib/merge.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import isArray from 'lodash/isArray.js';
|
|
2
|
+
import mergeWith from 'lodash/mergeWith.js';
|
|
3
3
|
|
|
4
4
|
function customizer (objValue, srcValue, key) {
|
|
5
5
|
if (objValue !== srcValue && isArray(objValue) && isArray(srcValue)) {
|
|
@@ -15,7 +15,7 @@ function customizer (objValue, srcValue, key) {
|
|
|
15
15
|
* @param {object|array} ...sources List of sources which to merge into object
|
|
16
16
|
* @returns {object|array} Merged object
|
|
17
17
|
*/
|
|
18
|
-
|
|
18
|
+
export default function merge (object, ...sources) {
|
|
19
19
|
for (let i = 0; i < sources.length; i++) {
|
|
20
20
|
if (sources[i] && typeof sources[i] === 'object') {
|
|
21
21
|
object = mergeWith(object, sources[i], customizer);
|
package/lib/run-preprocess.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import isPlainObject from 'lodash/isPlainObject.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Call all preprocess functions, preprocess validates and transforms configuration
|
|
@@ -6,7 +6,7 @@ const isPlainObject = require('lodash/isPlainObject');
|
|
|
6
6
|
* @param {object} taskConfig Task config
|
|
7
7
|
* @returns {object} Preprocessed task config
|
|
8
8
|
*/
|
|
9
|
-
|
|
9
|
+
export default function runPreprocess (taskConfig) {
|
|
10
10
|
if (taskConfig.preprocess) {
|
|
11
11
|
for (let taskName in taskConfig.preprocess) {
|
|
12
12
|
// Make sure task is not disabled
|
package/lib/task-order.js
CHANGED
|
@@ -1,24 +1,18 @@
|
|
|
1
|
-
const BEFORE_BUILD = 'beforeBuild';
|
|
2
|
-
const BUILD = 'build';
|
|
3
|
-
const AFTER_BUILD = 'afterBuild';
|
|
1
|
+
export const BEFORE_BUILD = 'beforeBuild';
|
|
2
|
+
export const BUILD = 'build';
|
|
3
|
+
export const AFTER_BUILD = 'afterBuild';
|
|
4
4
|
|
|
5
|
-
const BEFORE_WATCH = 'beforeWatch';
|
|
6
|
-
const WATCH = 'watch';
|
|
5
|
+
export const BEFORE_WATCH = 'beforeWatch';
|
|
6
|
+
export const WATCH = 'watch';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
exports.BUILD = BUILD;
|
|
10
|
-
exports.AFTER_BUILD = AFTER_BUILD;
|
|
11
|
-
exports.BEFORE_WATCH = BEFORE_WATCH;
|
|
12
|
-
exports.WATCH = WATCH;
|
|
13
|
-
|
|
14
|
-
exports.DEFAULT_TASKS = [
|
|
8
|
+
export const DEFAULT_TASKS = [
|
|
15
9
|
BEFORE_BUILD,
|
|
16
10
|
BUILD,
|
|
17
11
|
BEFORE_WATCH,
|
|
18
12
|
WATCH,
|
|
19
13
|
];
|
|
20
14
|
|
|
21
|
-
|
|
15
|
+
export const BUILD_TASKS = [
|
|
22
16
|
BEFORE_BUILD,
|
|
23
17
|
BUILD,
|
|
24
18
|
AFTER_BUILD,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@videinfra/static-website-builder",
|
|
3
|
-
"version": "2.0.0-beta.
|
|
3
|
+
"version": "2.0.0-beta.3",
|
|
4
4
|
"description": "Customizable static site project builder",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"engines": {
|
|
@@ -18,11 +18,13 @@
|
|
|
18
18
|
},
|
|
19
19
|
"main": "gulpfile.js/index.js",
|
|
20
20
|
"author": "Vide Infra",
|
|
21
|
+
"type": "module",
|
|
21
22
|
"scripts": {
|
|
22
|
-
"start": "cross-env BUILDER_MODE=development gulp",
|
|
23
|
+
"start": "cross-env BUILDER_MODE=development gulp watch",
|
|
23
24
|
"build": "cross-env BUILDER_MODE=production gulp build",
|
|
24
|
-
"test": "gulp build --silent --config=init/test/config/config.js && jest",
|
|
25
|
-
"test-watch": "gulp --config=init/test/config/config.js"
|
|
25
|
+
"test": "gulp build --silent --config=init/test/config/config.js && node --experimental-vm-modules node_modules/jest/bin/jest.js",
|
|
26
|
+
"test-watch": "gulp watch --config=init/test/config/config.js",
|
|
27
|
+
"test-builder": "node bin/builder.js build --config=init/test/config/config.js"
|
|
26
28
|
},
|
|
27
29
|
"dependencies": {
|
|
28
30
|
"@csstools/postcss-nested-calc": "^5.0.0",
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @param {object} fullConfig Full configuration
|
|
6
6
|
* @returns {object} Transformed example configuration
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
export default function preprocessExampleConfig (config = {}, fullConfig) {
|
|
9
9
|
// Do something with config, eg. add files starting with underscore to the ignore list.
|
|
10
10
|
// Ignore will be a list of globs, relative to the example source path, see task.js
|
|
11
11
|
config.ignore = config.ignore.concat([
|
package/plugins/example/task.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import gulp from 'gulp';
|
|
2
|
+
import { nanomemoize } from 'nano-memoize';
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
import globs from '@videinfra/example-website-builder/lib/globs-helper.js';
|
|
5
|
+
import { getTaskConfig } from '@videinfra/example-website-builder/lib/get-config.js';
|
|
6
|
+
import getPaths from '@videinfra/example-website-builder/lib/get-path.js';
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
8
|
+
import taskStart from '@videinfra/example-website-builder/lib/gulp/task-start.js';
|
|
9
|
+
import taskEnd from '@videinfra/example-website-builder/lib/gulp/task-end.js';
|
|
10
|
+
import taskWatch from '@videinfra/example-website-builder/lib/gulp/task-watch.js';
|
|
11
11
|
|
|
12
12
|
|
|
13
13
|
// Paths and files which gulp will watch and run on
|
|
14
14
|
// Using memoize to cache the result, for performance
|
|
15
15
|
const getWatchGlobPaths = function (forChokidar = false) {
|
|
16
16
|
const sourcePaths = getPaths.getSourcePaths('example');
|
|
17
|
-
const extensions =
|
|
18
|
-
const ignore =
|
|
17
|
+
const extensions = getTaskConfig('example', 'extensions');
|
|
18
|
+
const ignore = getTaskConfig('example', 'ignore');
|
|
19
19
|
|
|
20
20
|
// Combine source paths and extensions
|
|
21
21
|
return globs.generate(
|
|
@@ -23,7 +23,7 @@ const getWatchGlobPaths = function (forChokidar = false) {
|
|
|
23
23
|
globs.paths(sourcePaths).paths(ignore).ignore(), // Exclude files and folders from being processed
|
|
24
24
|
);
|
|
25
25
|
};
|
|
26
|
-
const getGlobPaths = nanomemoize(function () {
|
|
26
|
+
const getGlobPaths = nanomemoize.nanomemoize(function () {
|
|
27
27
|
return getWatchGlobPaths(false);
|
|
28
28
|
});
|
|
29
29
|
|
|
@@ -51,5 +51,5 @@ function exampleWatch () {
|
|
|
51
51
|
// Available tasks are: beforeWatch, watch, beforeBuild, build, afterBuild
|
|
52
52
|
// Execution order for development is: beforeBuild -> build-> beforeWatch -> watch
|
|
53
53
|
// Execution order for production is: beforeBuild -> build-> afterBuild
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
export const build = example;
|
|
55
|
+
export const watch = exampleWatch;
|
package/plugins/example.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Configuration for the example plugin
|
|
3
3
|
*/
|
|
4
|
+
import * as examplePreprocessConfig from './example/preprocess-config.js';
|
|
5
|
+
import * as exampleTask from './example/task.js';
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
export const example = {
|
|
6
8
|
// Glob list of files, which to ignore
|
|
7
9
|
// see https://gulpjs.com/docs/en/getting-started/explaining-globs/
|
|
8
10
|
ignore: [],
|
|
@@ -12,23 +14,23 @@ exports.example = {
|
|
|
12
14
|
};
|
|
13
15
|
|
|
14
16
|
// Function which can validate and modify configuration
|
|
15
|
-
|
|
17
|
+
export const preprocess = {
|
|
16
18
|
example: [
|
|
17
|
-
|
|
19
|
+
examplePreprocessConfig,
|
|
18
20
|
]
|
|
19
21
|
};
|
|
20
22
|
|
|
21
23
|
// Gulp task
|
|
22
|
-
|
|
24
|
+
export const tasks = {
|
|
23
25
|
example: [
|
|
24
|
-
|
|
26
|
+
exampleTask,
|
|
25
27
|
]
|
|
26
28
|
};
|
|
27
29
|
|
|
28
30
|
/**
|
|
29
31
|
* Paths relative to the global src and dest folders
|
|
30
32
|
*/
|
|
31
|
-
|
|
33
|
+
export const paths = {
|
|
32
34
|
example: {
|
|
33
35
|
'src': 'example',
|
|
34
36
|
'dest': 'assets/example',
|
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { getSourcePaths, getProjectPath } from './../../lib/get-path.js';
|
|
2
|
+
import { getTaskConfig } from './../../lib/get-config.js';
|
|
3
|
+
import merge from './../../lib/merge.js';
|
|
4
|
+
import getEnvData from './../../tasks/env/get-env.js';
|
|
5
|
+
import gulpSass from '../../vendor/gulp-sass/index.js';
|
|
6
|
+
import assign from 'lodash/assign.js';
|
|
7
|
+
import * as sass from 'sass';
|
|
9
8
|
|
|
10
9
|
/**
|
|
11
10
|
* Modify configuration
|
|
@@ -14,17 +13,17 @@ const gulpSass = require('../../vendor/gulp-sass/index');
|
|
|
14
13
|
* @param {object} fullConfig Full configuration
|
|
15
14
|
* @returns {object} Transformed stylesheet configuration
|
|
16
15
|
*/
|
|
17
|
-
|
|
16
|
+
export default function processSASSConfig(config, fullConfig) {
|
|
18
17
|
if (config && config.sass) {
|
|
19
18
|
if (config.sass.includePaths) {
|
|
20
19
|
// Map include paths to the project folder
|
|
21
|
-
config.sass.includePaths = config.sass.includePaths.map((path) =>
|
|
20
|
+
config.sass.includePaths = config.sass.includePaths.map((path) => getProjectPath(path));
|
|
22
21
|
} else {
|
|
23
22
|
config.sass.includePaths = [];
|
|
24
23
|
}
|
|
25
24
|
|
|
26
25
|
// Add stylesheet source path
|
|
27
|
-
const stylesheetSourcePath =
|
|
26
|
+
const stylesheetSourcePath = getSourcePaths('stylesheets');
|
|
28
27
|
|
|
29
28
|
stylesheetSourcePath.forEach((path) => {
|
|
30
29
|
if (!config.sass.includePaths.includes(path)) {
|
|
@@ -33,26 +32,23 @@ module.exports = function processSASSConfig (config, fullConfig) {
|
|
|
33
32
|
});
|
|
34
33
|
|
|
35
34
|
// Engine is a function which returns a gulp pipe function
|
|
36
|
-
config.engine = function getSASSEngine
|
|
37
|
-
const
|
|
38
|
-
const sassConfig =
|
|
35
|
+
config.engine = function getSASSEngine() {
|
|
36
|
+
const sassEngine = gulpSass(sass);
|
|
37
|
+
const sassConfig = getTaskConfig('stylesheets', 'sass');
|
|
39
38
|
|
|
40
39
|
if (config.legacy) {
|
|
41
40
|
sassConfig.silenceDeprecations = (sassConfig.silenceDeprecations || []).concat(['import', 'global-builtin', 'slash-div', 'color-functions']);
|
|
42
41
|
}
|
|
43
42
|
|
|
44
43
|
sassConfig.data = merge(getEnvData().sass, sassConfig.data || {});
|
|
45
|
-
return
|
|
44
|
+
return sassEngine(sassConfig, /* sync */ true).on('error', sassEngine.logError);
|
|
46
45
|
};
|
|
47
46
|
|
|
48
47
|
// Main 'dependents' config is shared between all tasks
|
|
49
48
|
if (config.dependents) {
|
|
50
|
-
|
|
51
49
|
for (let extension in config.dependents) {
|
|
52
50
|
config.dependents[extension].basePaths = config.dependents[extension].basePaths || [];
|
|
53
|
-
config.dependents[extension].basePaths = config.dependents[extension].basePaths.concat(
|
|
54
|
-
getPaths.getSourcePaths('stylesheets')
|
|
55
|
-
);
|
|
51
|
+
config.dependents[extension].basePaths = config.dependents[extension].basePaths.concat(getSourcePaths('stylesheets'));
|
|
56
52
|
}
|
|
57
53
|
|
|
58
54
|
fullConfig.dependents = assign(fullConfig.dependents || {}, config.dependents);
|
package/plugins/sass.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
+
import * as preprocessSassConfig from './sass-engine/preprocess-config.js';
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* SASS plugin attaches itself to the stylesheets task
|
|
3
5
|
*/
|
|
4
|
-
|
|
6
|
+
export const stylesheets = {
|
|
5
7
|
// Add sass to the extensions
|
|
6
8
|
extensions: ['scss', 'sass'],
|
|
7
9
|
|
|
@@ -32,8 +34,8 @@ exports.stylesheets = {
|
|
|
32
34
|
},
|
|
33
35
|
};
|
|
34
36
|
|
|
35
|
-
|
|
37
|
+
export const preprocess = {
|
|
36
38
|
stylesheets: [
|
|
37
|
-
|
|
39
|
+
preprocessSassConfig,
|
|
38
40
|
]
|
|
39
41
|
};
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
const exports = [];
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Filter with lodash 'omit' functionality
|
|
5
5
|
* !!!CAUTION!!! There is no filter in TWIG with this functionality!
|
|
6
6
|
*/
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
exports.push({
|
|
9
9
|
name: 'omit',
|
|
10
10
|
func: function (data, args) {
|
|
11
11
|
const output = {};
|
|
@@ -26,7 +26,7 @@ module.exports.push({
|
|
|
26
26
|
* !!!CAUTION!!! There is no filter in TWIG with this functionality!
|
|
27
27
|
*/
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
exports.push({
|
|
30
30
|
name: 'pick',
|
|
31
31
|
func: function (data, args) {
|
|
32
32
|
const output = {};
|
|
@@ -47,10 +47,10 @@ module.exports.push({
|
|
|
47
47
|
* !!!CAUTION!!! There is no filter in TWIG with this functionality!
|
|
48
48
|
*/
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
50
|
+
import filter from 'lodash/filter.js';
|
|
51
|
+
import omit from 'lodash/omit.js';
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
exports.push({
|
|
54
54
|
name: 'filter',
|
|
55
55
|
func: function (data, args) {
|
|
56
56
|
const predicate = omit(args[0], ['_keys']);
|
|
@@ -63,9 +63,9 @@ module.exports.push({
|
|
|
63
63
|
* !!!CAUTION!!! There is no reject in TWIG with this functionality!
|
|
64
64
|
*/
|
|
65
65
|
|
|
66
|
-
|
|
66
|
+
import reject from 'lodash/reject.js';
|
|
67
67
|
|
|
68
|
-
|
|
68
|
+
exports.push({
|
|
69
69
|
name: 'reject',
|
|
70
70
|
func: function (data, args) {
|
|
71
71
|
const predicate = omit(args[0], ['_keys']);
|
|
@@ -78,12 +78,14 @@ module.exports.push({
|
|
|
78
78
|
* !!!CAUTION!!! There is no filter in TWIG with this functionality!
|
|
79
79
|
*/
|
|
80
80
|
|
|
81
|
-
|
|
81
|
+
import find from 'lodash/find.js';
|
|
82
82
|
|
|
83
|
-
|
|
83
|
+
exports.push({
|
|
84
84
|
name: 'find',
|
|
85
85
|
func: function (data, args) {
|
|
86
86
|
const predicate = omit(args[0], ['_keys']);
|
|
87
87
|
return find(data, predicate);
|
|
88
88
|
}
|
|
89
89
|
});
|
|
90
|
+
|
|
91
|
+
export default exports;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
1
|
+
import filters from './lodash-filters/filters.js';
|
|
2
|
+
|
|
3
|
+
export const preprocess = {
|
|
2
4
|
html: [
|
|
3
5
|
function lodashFiltersPlugin (config) {
|
|
4
|
-
const filters = require('./lodash-filters/filters');
|
|
5
|
-
|
|
6
6
|
// Add filters to TWIG configurtion
|
|
7
7
|
config.twig = config.twig || {};
|
|
8
8
|
config.twig.filters = config.twig.filters || [];
|
|
@@ -1,4 +1,7 @@
|
|
|
1
|
-
|
|
1
|
+
import { getTaskConfig } from '../../../lib/get-config.js';
|
|
2
|
+
import preposition_nbsp from './preposition_nbsp.js';
|
|
3
|
+
|
|
4
|
+
const exports = [];
|
|
2
5
|
|
|
3
6
|
/**
|
|
4
7
|
* CDN filter
|
|
@@ -8,15 +11,14 @@ module.exports = [];
|
|
|
8
11
|
* {{ '/images/px.gif' | cdn }}
|
|
9
12
|
*/
|
|
10
13
|
|
|
11
|
-
const config = require('../../../lib/get-config');
|
|
12
14
|
const cdnsResourceMap = {};
|
|
13
15
|
let cdnIndex = -1;
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
exports.push({
|
|
16
18
|
name: 'cdnify',
|
|
17
19
|
func: function (path) {
|
|
18
20
|
const normalizedPath = (path || path === 0 ? String(path) : '');
|
|
19
|
-
const cdnsConfig =
|
|
21
|
+
const cdnsConfig = getTaskConfig('html', 'cdns');
|
|
20
22
|
|
|
21
23
|
if (cdnsResourceMap[normalizedPath]) return cdnsResourceMap[normalizedPath]; // cache so that same resource always use same cdn
|
|
22
24
|
if (!cdnsConfig || !cdnsConfig.length) return normalizedPath;
|
|
@@ -39,10 +41,10 @@ module.exports.push({
|
|
|
39
41
|
|
|
40
42
|
const version = Math.random().toString(36).replace(/[^a-z]+/g, '').substr(0, 5);
|
|
41
43
|
|
|
42
|
-
|
|
44
|
+
exports.push({
|
|
43
45
|
name: 'version',
|
|
44
46
|
func: function (path) {
|
|
45
|
-
if (!
|
|
47
|
+
if (!getTaskConfig('html', 'version')) return path;
|
|
46
48
|
|
|
47
49
|
const normalizedPath = (path || path === 0 ? String(path) : '');
|
|
48
50
|
const parts = normalizedPath.match(/^([^?#]*)(\?[^#]*)?(#.*)?$/i);
|
|
@@ -64,7 +66,7 @@ module.exports.push({
|
|
|
64
66
|
* Output: hello world
|
|
65
67
|
*/
|
|
66
68
|
|
|
67
|
-
|
|
69
|
+
exports.push({
|
|
68
70
|
name: 'humanize',
|
|
69
71
|
func: function (text) {
|
|
70
72
|
text = String(text);
|
|
@@ -87,12 +89,11 @@ module.exports.push({
|
|
|
87
89
|
* Output: hello at world
|
|
88
90
|
*/
|
|
89
91
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
module.exports.push({
|
|
92
|
+
exports.push({
|
|
93
93
|
name: 'preposition_nbsp',
|
|
94
94
|
func: function (text) {
|
|
95
95
|
return preposition_nbsp(text);
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
+
export default exports;
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
html: [
|
|
3
|
-
function symfonyFiltersPlugin (config) {
|
|
4
|
-
const filters = require('./symfony-filters/filters');
|
|
1
|
+
import filters from './symfony-filters/filters.js';
|
|
5
2
|
|
|
3
|
+
export const preprocess = {
|
|
4
|
+
html: [
|
|
5
|
+
function symfonyFiltersPlugin(config) {
|
|
6
6
|
// Add filters to TWIG configurtion
|
|
7
7
|
config.twig = config.twig || {};
|
|
8
8
|
config.twig.filters = config.twig.filters || [];
|
|
9
9
|
config.twig.filters = config.twig.filters.concat(filters);
|
|
10
10
|
|
|
11
11
|
return config;
|
|
12
|
-
}
|
|
13
|
-
]
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
14
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
import filters from '../symfony-filters/filters.js';
|
|
2
2
|
|
|
3
3
|
function applyFilter (filter) {
|
|
4
4
|
const args = [];
|
|
@@ -20,7 +20,7 @@ function applyFilter (filter) {
|
|
|
20
20
|
/**
|
|
21
21
|
* Symphony asset() TWIG function
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
export default [
|
|
24
24
|
{
|
|
25
25
|
name: 'asset',
|
|
26
26
|
func: function (path) {
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
html: [
|
|
3
|
-
function symfonyFunctionsPlugin (config) {
|
|
4
|
-
const functions = require('./symfony-functions/functions');
|
|
1
|
+
import functions from './symfony-functions/functions.js';
|
|
5
2
|
|
|
3
|
+
export const preprocess = {
|
|
4
|
+
html: [
|
|
5
|
+
function symfonyFunctionsPlugin(config) {
|
|
6
6
|
// Add functions to TWIG configurtion
|
|
7
7
|
config.twig = config.twig || {};
|
|
8
8
|
config.twig.functions = config.twig.functions || [];
|
|
9
9
|
config.twig.functions = config.twig.functions.concat(functions);
|
|
10
10
|
|
|
11
11
|
return config;
|
|
12
|
-
}
|
|
13
|
-
]
|
|
12
|
+
},
|
|
13
|
+
],
|
|
14
14
|
};
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
1
|
+
import twig from '../../vendor/gulp-twig/index.js';
|
|
2
|
+
import { getTaskConfig } from './../../lib/get-config.js';
|
|
3
|
+
import { getSourcePaths } from './../../lib/get-path.js';
|
|
4
|
+
import flattenDeep from 'lodash/flattenDeep.js';
|
|
5
|
+
import assign from 'lodash/assign.js';
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
/**
|
|
@@ -12,13 +12,13 @@ const assign = require('lodash/assign');
|
|
|
12
12
|
* @param {object} fullConfig Full configuration
|
|
13
13
|
* @returns {object} Transformed HTML configuration
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
export default function preprocessHTMLConfig (config = {}, fullConfig) {
|
|
16
16
|
if (config.twig) {
|
|
17
|
-
config.twig.base =
|
|
17
|
+
config.twig.base = getSourcePaths('html');
|
|
18
18
|
|
|
19
19
|
// Engine is a function which returns a gulp pipe function
|
|
20
20
|
config.engine = function getTwigEngine () {
|
|
21
|
-
return twig(
|
|
21
|
+
return twig(getTaskConfig('html', 'twig'));
|
|
22
22
|
};
|
|
23
23
|
|
|
24
24
|
if (config.twig.functions) {
|
package/plugins/twig.js
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
import * as preprocessTwigConfig from './twig-engine/preprocess-config.js';
|
|
2
|
+
// import * as symfonyFunctions from './twig/symfony-functions.js';
|
|
3
|
+
// import * as symfonyFilters from './twig/symfony-filters.js';
|
|
4
|
+
// import * as lodashFilters from './twig/lodash-filters.js';
|
|
5
|
+
|
|
1
6
|
/**
|
|
2
7
|
* TWIG plugin attaches itself to the HTML task
|
|
3
8
|
*/
|
|
4
|
-
|
|
9
|
+
export const html = {
|
|
5
10
|
// Add twig to the extensions
|
|
6
11
|
extensions: ['twig'],
|
|
7
12
|
|
|
@@ -39,13 +44,13 @@ exports.html = {
|
|
|
39
44
|
|
|
40
45
|
// Custom functions
|
|
41
46
|
functions: [
|
|
42
|
-
//
|
|
47
|
+
// symfonyFunctions,
|
|
43
48
|
],
|
|
44
49
|
|
|
45
50
|
// Custom filters
|
|
46
51
|
filters: [
|
|
47
|
-
//
|
|
48
|
-
//
|
|
52
|
+
// lodashFilters,
|
|
53
|
+
// symfonyFilters,
|
|
49
54
|
],
|
|
50
55
|
|
|
51
56
|
// Production only settings, overwrites default settings
|
|
@@ -62,8 +67,8 @@ exports.html = {
|
|
|
62
67
|
version: false,
|
|
63
68
|
};
|
|
64
69
|
|
|
65
|
-
|
|
70
|
+
export const preprocess = {
|
|
66
71
|
html: [
|
|
67
|
-
|
|
72
|
+
preprocessTwigConfig,
|
|
68
73
|
]
|
|
69
74
|
};
|
|
@@ -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
|