@videinfra/static-website-builder 1.12.0 → 1.12.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +4 -0
- package/init/index.js +56 -56
- package/init/test/config/config.js +36 -36
- package/init/test/src/stylesheets/autoprefixer-test.scss +3 -3
- package/init/test/src/stylesheets/ignore-test.scss +4 -4
- package/init/test/src/stylesheets/nested-calc-test.scss +3 -3
- package/init/test/src/stylesheets/sub-folder/import-test.scss +2 -2
- package/lib/camelize-file-name.js +21 -21
- package/lib/get-file-names.js +23 -23
- package/lib/get-path.js +109 -109
- package/lib/globs-helper.js +136 -136
- package/lib/log-error.js +15 -15
- package/lib/merge.js +27 -27
- package/package.json +1 -1
- package/plugins/sass-engine/preprocess-config.js +54 -54
- package/plugins/sass.js +38 -38
- package/plugins/twig-engine/preprocess-config.js +47 -47
- package/plugins/twig.js +65 -65
- package/tasks/data/data-loader-js.js +5 -5
- package/tasks/data/get-data.js +87 -87
- package/tasks/html/task.js +91 -91
- package/tasks/icons/config.js +52 -52
- package/tasks/javascripts/preprocess-config.js +2 -0
- package/tasks/javascripts/webpack-url-version.js +32 -0
- package/tasks/stylesheets/config.js +88 -88
- package/tasks/stylesheets/preprocess-config.js +41 -41
- package/tasks/stylesheets/task.js +69 -69
- package/tests/build/build.test.js +101 -101
- package/tests/camelize-file-name.test.js +11 -11
- package/tests/glob-helper.test.js +99 -99
- package/vendor/gulp-twig/LICENSE +20 -20
- package/vendor/gulp-twig/README.md +167 -167
- package/vendor/gulp-twig/index.js +130 -130
- package/vendor/gulp-twig/package.json +43 -43
package/lib/globs-helper.js
CHANGED
|
@@ -1,136 +1,136 @@
|
|
|
1
|
-
const path = require('path');
|
|
2
|
-
const flatten = require('lodash/flatten');
|
|
3
|
-
const map = require('lodash/map');
|
|
4
|
-
const filter = require('lodash/filter');
|
|
5
|
-
|
|
6
|
-
const REGEX_DOT_PREFIX = /^\.+/;
|
|
7
|
-
const REGEX_WINDOWS_BACKSLASH = /\\/g;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
class GlobObject {
|
|
11
|
-
constructor () {
|
|
12
|
-
this.hadEmptyPaths = false;
|
|
13
|
-
this.isIgnore = false;
|
|
14
|
-
this.hasExtensions = false;
|
|
15
|
-
this.pathsArr = [];
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
paths (paths) {
|
|
19
|
-
const pathsArr = Array.isArray(paths) ? paths : (typeof paths === 'string' ? [paths] : []);
|
|
20
|
-
|
|
21
|
-
if (pathsArr.length) {
|
|
22
|
-
if (this.pathsArr.length) {
|
|
23
|
-
this.map((basePath) => {
|
|
24
|
-
return pathsArr.map((subPath) => {
|
|
25
|
-
// If subpath starts with specia character "!" then prepend that to the begining of full paths
|
|
26
|
-
const negativePath = subPath[0] === '!' ? '!' : '';
|
|
27
|
-
const subPathNormalized = negativePath ? subPath.substr(1) : subPath;
|
|
28
|
-
return negativePath + path.join(basePath, subPathNormalized);
|
|
29
|
-
});
|
|
30
|
-
});
|
|
31
|
-
} else {
|
|
32
|
-
this.pathsArr = pathsArr;
|
|
33
|
-
}
|
|
34
|
-
} else {
|
|
35
|
-
this.hadEmptyPaths = true;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
return this;
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Adds extensions to the paths
|
|
43
|
-
*
|
|
44
|
-
* @param {string|array} extensions An extension or list of extensions
|
|
45
|
-
* @returns {object} GlobObject
|
|
46
|
-
*/
|
|
47
|
-
filesWithExtensions (extensions) {
|
|
48
|
-
const extensionsArr = typeof extensions === 'string' ? [extensions] : extensions;
|
|
49
|
-
|
|
50
|
-
if (extensionsArr && extensionsArr.length) {
|
|
51
|
-
let extensionString = '';
|
|
52
|
-
|
|
53
|
-
// Remove dot from the extension name
|
|
54
|
-
let extensionsArrNormalized = map(extensionsArr, (extension) => extension.replace(REGEX_DOT_PREFIX, ''));
|
|
55
|
-
|
|
56
|
-
if (extensionsArrNormalized.length > 1) {
|
|
57
|
-
extensionString = `/**/*.{${ extensionsArrNormalized.join(',') }}`;
|
|
58
|
-
} else {
|
|
59
|
-
extensionString = `/**/*.${ extensionsArrNormalized }`;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
this.hasExtensions = true;
|
|
63
|
-
return this.map((path) => `${ path }${ extensionString }`);
|
|
64
|
-
} else {
|
|
65
|
-
return this;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
/**
|
|
70
|
-
* Add a wildcard to select all files
|
|
71
|
-
*
|
|
72
|
-
* @returns {object} GlobObject
|
|
73
|
-
*/
|
|
74
|
-
allFiles () {
|
|
75
|
-
return this.map((path) => `${ path }/**`);
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Adds all paths to the ignore list
|
|
80
|
-
*
|
|
81
|
-
* @returns {object} GlobObject
|
|
82
|
-
*/
|
|
83
|
-
ignore () {
|
|
84
|
-
this.isIgnore = true;
|
|
85
|
-
return this.map((path) => `!${ path }`);
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Itterates through all paths
|
|
90
|
-
*
|
|
91
|
-
* @param {function} fn Itteratee function
|
|
92
|
-
* @returns {object} GlobObject
|
|
93
|
-
*/
|
|
94
|
-
map (fn) {
|
|
95
|
-
this.pathsArr = filter(flatten(map(this.pathsArr, fn)), (path) => !!path);
|
|
96
|
-
return this;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
/**
|
|
100
|
-
* Converts paths to an array of normalized glob paths
|
|
101
|
-
*
|
|
102
|
-
* @returns {array} Array of glob paths
|
|
103
|
-
*/
|
|
104
|
-
toArray () {
|
|
105
|
-
if (this.hadEmptyPaths && this.isIgnore) {
|
|
106
|
-
// Since we exclude files / paths, don't return anything if path list was empty
|
|
107
|
-
return [];
|
|
108
|
-
} else {
|
|
109
|
-
return map(this.pathsArr, (path) => {
|
|
110
|
-
return path.replace(REGEX_WINDOWS_BACKSLASH, '/');
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Alias for toArray
|
|
117
|
-
*
|
|
118
|
-
* @returns {array} Array of glob paths
|
|
119
|
-
*/
|
|
120
|
-
generate () {
|
|
121
|
-
return this.toArray();
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
function paths (paths) {
|
|
126
|
-
return (new GlobObject()).paths(paths);
|
|
127
|
-
}
|
|
128
|
-
|
|
129
|
-
function generate (...globs) {
|
|
130
|
-
return flatten(map(flatten(globs), (glob) => glob.toArray()));
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
module.exports = {
|
|
134
|
-
generate,
|
|
135
|
-
paths,
|
|
136
|
-
};
|
|
1
|
+
const path = require('path');
|
|
2
|
+
const flatten = require('lodash/flatten');
|
|
3
|
+
const map = require('lodash/map');
|
|
4
|
+
const filter = require('lodash/filter');
|
|
5
|
+
|
|
6
|
+
const REGEX_DOT_PREFIX = /^\.+/;
|
|
7
|
+
const REGEX_WINDOWS_BACKSLASH = /\\/g;
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
class GlobObject {
|
|
11
|
+
constructor () {
|
|
12
|
+
this.hadEmptyPaths = false;
|
|
13
|
+
this.isIgnore = false;
|
|
14
|
+
this.hasExtensions = false;
|
|
15
|
+
this.pathsArr = [];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
paths (paths) {
|
|
19
|
+
const pathsArr = Array.isArray(paths) ? paths : (typeof paths === 'string' ? [paths] : []);
|
|
20
|
+
|
|
21
|
+
if (pathsArr.length) {
|
|
22
|
+
if (this.pathsArr.length) {
|
|
23
|
+
this.map((basePath) => {
|
|
24
|
+
return pathsArr.map((subPath) => {
|
|
25
|
+
// If subpath starts with specia character "!" then prepend that to the begining of full paths
|
|
26
|
+
const negativePath = subPath[0] === '!' ? '!' : '';
|
|
27
|
+
const subPathNormalized = negativePath ? subPath.substr(1) : subPath;
|
|
28
|
+
return negativePath + path.join(basePath, subPathNormalized);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
} else {
|
|
32
|
+
this.pathsArr = pathsArr;
|
|
33
|
+
}
|
|
34
|
+
} else {
|
|
35
|
+
this.hadEmptyPaths = true;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return this;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* Adds extensions to the paths
|
|
43
|
+
*
|
|
44
|
+
* @param {string|array} extensions An extension or list of extensions
|
|
45
|
+
* @returns {object} GlobObject
|
|
46
|
+
*/
|
|
47
|
+
filesWithExtensions (extensions) {
|
|
48
|
+
const extensionsArr = typeof extensions === 'string' ? [extensions] : extensions;
|
|
49
|
+
|
|
50
|
+
if (extensionsArr && extensionsArr.length) {
|
|
51
|
+
let extensionString = '';
|
|
52
|
+
|
|
53
|
+
// Remove dot from the extension name
|
|
54
|
+
let extensionsArrNormalized = map(extensionsArr, (extension) => extension.replace(REGEX_DOT_PREFIX, ''));
|
|
55
|
+
|
|
56
|
+
if (extensionsArrNormalized.length > 1) {
|
|
57
|
+
extensionString = `/**/*.{${ extensionsArrNormalized.join(',') }}`;
|
|
58
|
+
} else {
|
|
59
|
+
extensionString = `/**/*.${ extensionsArrNormalized }`;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
this.hasExtensions = true;
|
|
63
|
+
return this.map((path) => `${ path }${ extensionString }`);
|
|
64
|
+
} else {
|
|
65
|
+
return this;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/**
|
|
70
|
+
* Add a wildcard to select all files
|
|
71
|
+
*
|
|
72
|
+
* @returns {object} GlobObject
|
|
73
|
+
*/
|
|
74
|
+
allFiles () {
|
|
75
|
+
return this.map((path) => `${ path }/**`);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* Adds all paths to the ignore list
|
|
80
|
+
*
|
|
81
|
+
* @returns {object} GlobObject
|
|
82
|
+
*/
|
|
83
|
+
ignore () {
|
|
84
|
+
this.isIgnore = true;
|
|
85
|
+
return this.map((path) => `!${ path }`);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Itterates through all paths
|
|
90
|
+
*
|
|
91
|
+
* @param {function} fn Itteratee function
|
|
92
|
+
* @returns {object} GlobObject
|
|
93
|
+
*/
|
|
94
|
+
map (fn) {
|
|
95
|
+
this.pathsArr = filter(flatten(map(this.pathsArr, fn)), (path) => !!path);
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Converts paths to an array of normalized glob paths
|
|
101
|
+
*
|
|
102
|
+
* @returns {array} Array of glob paths
|
|
103
|
+
*/
|
|
104
|
+
toArray () {
|
|
105
|
+
if (this.hadEmptyPaths && this.isIgnore) {
|
|
106
|
+
// Since we exclude files / paths, don't return anything if path list was empty
|
|
107
|
+
return [];
|
|
108
|
+
} else {
|
|
109
|
+
return map(this.pathsArr, (path) => {
|
|
110
|
+
return path.replace(REGEX_WINDOWS_BACKSLASH, '/');
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Alias for toArray
|
|
117
|
+
*
|
|
118
|
+
* @returns {array} Array of glob paths
|
|
119
|
+
*/
|
|
120
|
+
generate () {
|
|
121
|
+
return this.toArray();
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function paths (paths) {
|
|
126
|
+
return (new GlobObject()).paths(paths);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function generate (...globs) {
|
|
130
|
+
return flatten(map(flatten(globs), (glob) => glob.toArray()));
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
module.exports = {
|
|
134
|
+
generate,
|
|
135
|
+
paths,
|
|
136
|
+
};
|
package/lib/log-error.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
const chalk = require('chalk');
|
|
2
|
-
|
|
3
|
-
module.exports = function (error) {
|
|
4
|
-
if (error.plugin) {
|
|
5
|
-
console.log('Error \'' + chalk.cyan(error.plugin) + '\' ' + chalk.red(error.message));
|
|
6
|
-
|
|
7
|
-
} else {
|
|
8
|
-
console.log(error.toString().split(': ').join(':\n'));
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
// Emit the end event, to properly end the task
|
|
12
|
-
if (typeof this.emit === 'function') {
|
|
13
|
-
this.emit('end');
|
|
14
|
-
}
|
|
15
|
-
}
|
|
1
|
+
const chalk = require('chalk');
|
|
2
|
+
|
|
3
|
+
module.exports = function (error) {
|
|
4
|
+
if (error.plugin) {
|
|
5
|
+
console.log('Error \'' + chalk.cyan(error.plugin) + '\' ' + chalk.red(error.message));
|
|
6
|
+
|
|
7
|
+
} else {
|
|
8
|
+
console.log(error.toString().split(': ').join(':\n'));
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
// Emit the end event, to properly end the task
|
|
12
|
+
if (typeof this.emit === 'function') {
|
|
13
|
+
this.emit('end');
|
|
14
|
+
}
|
|
15
|
+
}
|
package/lib/merge.js
CHANGED
|
@@ -1,27 +1,27 @@
|
|
|
1
|
-
const isArray = require('lodash/isArray');
|
|
2
|
-
const mergeWith = require('lodash/mergeWith');
|
|
3
|
-
|
|
4
|
-
function customizer (objValue, srcValue, key) {
|
|
5
|
-
if (objValue !== srcValue && isArray(objValue) && isArray(srcValue)) {
|
|
6
|
-
return objValue.concat(srcValue);
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Merge multiple objest together, with array concatanation
|
|
12
|
-
* object is mutated
|
|
13
|
-
*
|
|
14
|
-
* @param {object|array} object Object into which to merge into
|
|
15
|
-
* @param {object|array} ...sources List of sources which to merge into object
|
|
16
|
-
* @returns {object|array} Merged object
|
|
17
|
-
*/
|
|
18
|
-
module.exports = function merge (object, ...sources) {
|
|
19
|
-
for (let i = 0; i < sources.length; i++) {
|
|
20
|
-
if (sources[i] && typeof sources[i] === 'object') {
|
|
21
|
-
object = mergeWith(object, sources[i], customizer);
|
|
22
|
-
} else {
|
|
23
|
-
object = sources[i];
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
return object;
|
|
27
|
-
}
|
|
1
|
+
const isArray = require('lodash/isArray');
|
|
2
|
+
const mergeWith = require('lodash/mergeWith');
|
|
3
|
+
|
|
4
|
+
function customizer (objValue, srcValue, key) {
|
|
5
|
+
if (objValue !== srcValue && isArray(objValue) && isArray(srcValue)) {
|
|
6
|
+
return objValue.concat(srcValue);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Merge multiple objest together, with array concatanation
|
|
12
|
+
* object is mutated
|
|
13
|
+
*
|
|
14
|
+
* @param {object|array} object Object into which to merge into
|
|
15
|
+
* @param {object|array} ...sources List of sources which to merge into object
|
|
16
|
+
* @returns {object|array} Merged object
|
|
17
|
+
*/
|
|
18
|
+
module.exports = function merge (object, ...sources) {
|
|
19
|
+
for (let i = 0; i < sources.length; i++) {
|
|
20
|
+
if (sources[i] && typeof sources[i] === 'object') {
|
|
21
|
+
object = mergeWith(object, sources[i], customizer);
|
|
22
|
+
} else {
|
|
23
|
+
object = sources[i];
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return object;
|
|
27
|
+
}
|
package/package.json
CHANGED
|
@@ -1,54 +1,54 @@
|
|
|
1
|
-
const paths = require('./../../lib/get-path');
|
|
2
|
-
const getConfig = require('./../../lib/get-config');
|
|
3
|
-
const getPaths = require('./../../lib/get-path');
|
|
4
|
-
const assign = require('lodash/assign');
|
|
5
|
-
const gulpSass = require('gulp-sass');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Modify configuration
|
|
10
|
-
*
|
|
11
|
-
* @param {object} config Stylesheet configuration
|
|
12
|
-
* @param {object} fullConfig Full configuration
|
|
13
|
-
* @returns {object} Transformed stylesheet configuration
|
|
14
|
-
*/
|
|
15
|
-
module.exports = function processSASSConfig (config, fullConfig) {
|
|
16
|
-
if (config && config.sass) {
|
|
17
|
-
if (config.sass.includePaths) {
|
|
18
|
-
// Map include paths to the project folder
|
|
19
|
-
config.sass.includePaths = config.sass.includePaths.map((path) => paths.getProjectPath(path));
|
|
20
|
-
} else {
|
|
21
|
-
config.sass.includePaths = [];
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
// Add stylesheet source path
|
|
25
|
-
const stylesheetSourcePath = getPaths.getSourcePaths('stylesheets')
|
|
26
|
-
|
|
27
|
-
stylesheetSourcePath.forEach((path) => {
|
|
28
|
-
if (!config.sass.includePaths.includes(path)) {
|
|
29
|
-
config.sass.includePaths.push(path);
|
|
30
|
-
}
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
// Engine is a function which returns a gulp pipe function
|
|
34
|
-
config.engine = function getSASSEngine () {
|
|
35
|
-
const sass = config.legacy ? gulpSass(require('node-sass')) : gulpSass(require('sass'));
|
|
36
|
-
return sass(getConfig.getTaskConfig('stylesheets', 'sass')).on('error', sass.logError)
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
// Main 'dependents' config is shared between all tasks
|
|
40
|
-
if (config.dependents) {
|
|
41
|
-
|
|
42
|
-
for (let extension in config.dependents) {
|
|
43
|
-
config.dependents[extension].basePaths = config.dependents[extension].basePaths || [];
|
|
44
|
-
config.dependents[extension].basePaths = config.dependents[extension].basePaths.concat(
|
|
45
|
-
getPaths.getSourcePaths('stylesheets')
|
|
46
|
-
);
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
fullConfig.dependents = assign(fullConfig.dependents || {}, config.dependents);
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
return config;
|
|
54
|
-
}
|
|
1
|
+
const paths = require('./../../lib/get-path');
|
|
2
|
+
const getConfig = require('./../../lib/get-config');
|
|
3
|
+
const getPaths = require('./../../lib/get-path');
|
|
4
|
+
const assign = require('lodash/assign');
|
|
5
|
+
const gulpSass = require('gulp-sass');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Modify configuration
|
|
10
|
+
*
|
|
11
|
+
* @param {object} config Stylesheet configuration
|
|
12
|
+
* @param {object} fullConfig Full configuration
|
|
13
|
+
* @returns {object} Transformed stylesheet configuration
|
|
14
|
+
*/
|
|
15
|
+
module.exports = function processSASSConfig (config, fullConfig) {
|
|
16
|
+
if (config && config.sass) {
|
|
17
|
+
if (config.sass.includePaths) {
|
|
18
|
+
// Map include paths to the project folder
|
|
19
|
+
config.sass.includePaths = config.sass.includePaths.map((path) => paths.getProjectPath(path));
|
|
20
|
+
} else {
|
|
21
|
+
config.sass.includePaths = [];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// Add stylesheet source path
|
|
25
|
+
const stylesheetSourcePath = getPaths.getSourcePaths('stylesheets')
|
|
26
|
+
|
|
27
|
+
stylesheetSourcePath.forEach((path) => {
|
|
28
|
+
if (!config.sass.includePaths.includes(path)) {
|
|
29
|
+
config.sass.includePaths.push(path);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
// Engine is a function which returns a gulp pipe function
|
|
34
|
+
config.engine = function getSASSEngine () {
|
|
35
|
+
const sass = config.legacy ? gulpSass(require('node-sass')) : gulpSass(require('sass'));
|
|
36
|
+
return sass(getConfig.getTaskConfig('stylesheets', 'sass')).on('error', sass.logError)
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
// Main 'dependents' config is shared between all tasks
|
|
40
|
+
if (config.dependents) {
|
|
41
|
+
|
|
42
|
+
for (let extension in config.dependents) {
|
|
43
|
+
config.dependents[extension].basePaths = config.dependents[extension].basePaths || [];
|
|
44
|
+
config.dependents[extension].basePaths = config.dependents[extension].basePaths.concat(
|
|
45
|
+
getPaths.getSourcePaths('stylesheets')
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
fullConfig.dependents = assign(fullConfig.dependents || {}, config.dependents);
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
return config;
|
|
54
|
+
}
|
package/plugins/sass.js
CHANGED
|
@@ -1,38 +1,38 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* SASS plugin attaches itself to the stylesheets task
|
|
3
|
-
*/
|
|
4
|
-
exports.stylesheets = {
|
|
5
|
-
// Add sass to the extensions
|
|
6
|
-
extensions: ['scss', 'sass'],
|
|
7
|
-
|
|
8
|
-
// Use legacy `node-sass` instead of `sass`
|
|
9
|
-
legacy: true,
|
|
10
|
-
|
|
11
|
-
// SASS options
|
|
12
|
-
// see https://github.com/sass/node-sass#options
|
|
13
|
-
sass: {
|
|
14
|
-
includePaths: ['./node_modules'],
|
|
15
|
-
},
|
|
16
|
-
|
|
17
|
-
// Dependents plugin for faster builds
|
|
18
|
-
dependents: {
|
|
19
|
-
'.scss': {
|
|
20
|
-
parserSteps:
|
|
21
|
-
[
|
|
22
|
-
// The language semantics allow import statements with a comma-separated list of file paths.
|
|
23
|
-
// Therefore, we first extract the whole statement, and then extract each of the paths from that.
|
|
24
|
-
/(?:^|;|{|}|\*\/)\s*@(import|use|forward)\s+((?:"[^"]+"|'[^']+'|url\((?:"[^"]+"|'[^']+'|[^)]+)\))(?:\s*,\s*(?:"[^"]+"|'[^']+'|url\((?:"[^"]+"|'[^']+'|[^)]+)\)))*)(?=[^;]*;)/gm,
|
|
25
|
-
/"([^"]+)"|'([^']+)'|url\((?:"([^"]+)"|'([^']+)'|([^)]+))\)/gm
|
|
26
|
-
],
|
|
27
|
-
prefixes: ['', '_'],
|
|
28
|
-
postfixes: ['.scss', '.sass'],
|
|
29
|
-
basePaths: []
|
|
30
|
-
},
|
|
31
|
-
},
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
exports.preprocess = {
|
|
35
|
-
stylesheets: [
|
|
36
|
-
require('./sass-engine/preprocess-config'),
|
|
37
|
-
]
|
|
38
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* SASS plugin attaches itself to the stylesheets task
|
|
3
|
+
*/
|
|
4
|
+
exports.stylesheets = {
|
|
5
|
+
// Add sass to the extensions
|
|
6
|
+
extensions: ['scss', 'sass'],
|
|
7
|
+
|
|
8
|
+
// Use legacy `node-sass` instead of `sass`
|
|
9
|
+
legacy: true,
|
|
10
|
+
|
|
11
|
+
// SASS options
|
|
12
|
+
// see https://github.com/sass/node-sass#options
|
|
13
|
+
sass: {
|
|
14
|
+
includePaths: ['./node_modules'],
|
|
15
|
+
},
|
|
16
|
+
|
|
17
|
+
// Dependents plugin for faster builds
|
|
18
|
+
dependents: {
|
|
19
|
+
'.scss': {
|
|
20
|
+
parserSteps:
|
|
21
|
+
[
|
|
22
|
+
// The language semantics allow import statements with a comma-separated list of file paths.
|
|
23
|
+
// Therefore, we first extract the whole statement, and then extract each of the paths from that.
|
|
24
|
+
/(?:^|;|{|}|\*\/)\s*@(import|use|forward)\s+((?:"[^"]+"|'[^']+'|url\((?:"[^"]+"|'[^']+'|[^)]+)\))(?:\s*,\s*(?:"[^"]+"|'[^']+'|url\((?:"[^"]+"|'[^']+'|[^)]+)\)))*)(?=[^;]*;)/gm,
|
|
25
|
+
/"([^"]+)"|'([^']+)'|url\((?:"([^"]+)"|'([^']+)'|([^)]+))\)/gm
|
|
26
|
+
],
|
|
27
|
+
prefixes: ['', '_'],
|
|
28
|
+
postfixes: ['.scss', '.sass'],
|
|
29
|
+
basePaths: []
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
exports.preprocess = {
|
|
35
|
+
stylesheets: [
|
|
36
|
+
require('./sass-engine/preprocess-config'),
|
|
37
|
+
]
|
|
38
|
+
};
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
const twig = require('../../vendor/gulp-twig/index');
|
|
2
|
-
const getConfig = require('./../../lib/get-config');
|
|
3
|
-
const getPaths = require('./../../lib/get-path');
|
|
4
|
-
const flattenDeep = require('lodash/flattenDeep');
|
|
5
|
-
const assign = require('lodash/assign');
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Modify configuration
|
|
10
|
-
*
|
|
11
|
-
* @param {object} config HTML configuration
|
|
12
|
-
* @param {object} fullConfig Full configuration
|
|
13
|
-
* @returns {object} Transformed HTML configuration
|
|
14
|
-
*/
|
|
15
|
-
module.exports = function preprocessHTMLConfig (config = {}, fullConfig) {
|
|
16
|
-
if (config.twig) {
|
|
17
|
-
config.twig.base = getPaths.getSourcePaths('html');
|
|
18
|
-
|
|
19
|
-
// Engine is a function which returns a gulp pipe function
|
|
20
|
-
config.engine = function getTwigEngine () {
|
|
21
|
-
return twig(getConfig.getTaskConfig('html', 'twig'));
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
if (config.twig.functions) {
|
|
25
|
-
config.twig.functions = flattenDeep(config.twig.functions);
|
|
26
|
-
}
|
|
27
|
-
if (config.twig.filters) {
|
|
28
|
-
config.twig.filters = flattenDeep(config.twig.filters);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// Main 'dependents' config is shared between all tasks
|
|
32
|
-
if (config.dependents) {
|
|
33
|
-
for (let extension in config.dependents) {
|
|
34
|
-
config.dependents[extension].basePaths = config.dependents[extension].basePaths || [];
|
|
35
|
-
config.dependents[extension].basePaths = config.dependents[extension].basePaths.concat(
|
|
36
|
-
config.twig.base
|
|
37
|
-
);
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
fullConfig.dependents = assign(fullConfig.dependents || {}, config.dependents);
|
|
41
|
-
}
|
|
42
|
-
} else {
|
|
43
|
-
config.twig = false;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
return config;
|
|
47
|
-
}
|
|
1
|
+
const twig = require('../../vendor/gulp-twig/index');
|
|
2
|
+
const getConfig = require('./../../lib/get-config');
|
|
3
|
+
const getPaths = require('./../../lib/get-path');
|
|
4
|
+
const flattenDeep = require('lodash/flattenDeep');
|
|
5
|
+
const assign = require('lodash/assign');
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Modify configuration
|
|
10
|
+
*
|
|
11
|
+
* @param {object} config HTML configuration
|
|
12
|
+
* @param {object} fullConfig Full configuration
|
|
13
|
+
* @returns {object} Transformed HTML configuration
|
|
14
|
+
*/
|
|
15
|
+
module.exports = function preprocessHTMLConfig (config = {}, fullConfig) {
|
|
16
|
+
if (config.twig) {
|
|
17
|
+
config.twig.base = getPaths.getSourcePaths('html');
|
|
18
|
+
|
|
19
|
+
// Engine is a function which returns a gulp pipe function
|
|
20
|
+
config.engine = function getTwigEngine () {
|
|
21
|
+
return twig(getConfig.getTaskConfig('html', 'twig'));
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
if (config.twig.functions) {
|
|
25
|
+
config.twig.functions = flattenDeep(config.twig.functions);
|
|
26
|
+
}
|
|
27
|
+
if (config.twig.filters) {
|
|
28
|
+
config.twig.filters = flattenDeep(config.twig.filters);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Main 'dependents' config is shared between all tasks
|
|
32
|
+
if (config.dependents) {
|
|
33
|
+
for (let extension in config.dependents) {
|
|
34
|
+
config.dependents[extension].basePaths = config.dependents[extension].basePaths || [];
|
|
35
|
+
config.dependents[extension].basePaths = config.dependents[extension].basePaths.concat(
|
|
36
|
+
config.twig.base
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
fullConfig.dependents = assign(fullConfig.dependents || {}, config.dependents);
|
|
41
|
+
}
|
|
42
|
+
} else {
|
|
43
|
+
config.twig = false;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
return config;
|
|
47
|
+
}
|