mod-build 3.6.29 → 3.6.31-beta.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/gulp-tasks/build.js +3 -3
- package/gulp-tasks/copy-videos.js +6 -0
- package/gulp-tasks/grab-global-images.js +26 -14
- package/gulp-tasks/tasks.js +12 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/gulp-tasks/build.js
CHANGED
|
@@ -8,12 +8,12 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
|
|
|
8
8
|
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'compile-prod', 'js-lint', 'html-min', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'build-stat'];
|
|
9
9
|
} else if (siteData.isWhiteLabel) {
|
|
10
10
|
if (siteData.isQSPage) {
|
|
11
|
-
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'grab-theme-json', 'combine-files', 'grab-images', 'copy-json', 'js-lint', 'html-min', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'copy-files-to-build-path', 'cache-bust', 'grab-tooltips-json', 'build-stat'];
|
|
11
|
+
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'copy-videos', 'grab-theme-json', 'combine-files', 'grab-images', 'copy-json', 'js-lint', 'html-min', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'copy-files-to-build-path', 'cache-bust', 'grab-tooltips-json', 'build-stat'];
|
|
12
12
|
} else {
|
|
13
|
-
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'combine-files', 'grab-images', 'js-lint', 'html-min','grab-global-images', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'grab-tooltips-json', 'build-stat'];
|
|
13
|
+
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'copy-videos', 'combine-files', 'grab-images', 'js-lint', 'html-min','grab-global-images', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'grab-tooltips-json', 'build-stat'];
|
|
14
14
|
}
|
|
15
15
|
} else {
|
|
16
|
-
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'js-lint', 'html-min', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'build-stat'];
|
|
16
|
+
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'copy-videos', 'js-lint', 'html-min', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'build-stat'];
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
runSequence(...sequenceOpts, function() {
|
|
@@ -2,11 +2,22 @@ var fs = require('fs');
|
|
|
2
2
|
var request = require('request');
|
|
3
3
|
var source = require('vinyl-source-stream');
|
|
4
4
|
var replace = require('gulp-replace');
|
|
5
|
+
var path = require('path')
|
|
5
6
|
|
|
6
|
-
var
|
|
7
|
+
var imagePaths = [];
|
|
7
8
|
|
|
8
|
-
function
|
|
9
|
-
|
|
9
|
+
function getFilePathFromURL(url) {
|
|
10
|
+
let pathName = new URL(url).pathname;
|
|
11
|
+
pathName = pathName.substring(0, pathName.lastIndexOf('/'));
|
|
12
|
+
pathName = pathName.replace('/quote/resources/', '');
|
|
13
|
+
|
|
14
|
+
return pathName;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function streamToDestination(gulp, siteSettings, url) {
|
|
18
|
+
let finalDestination;
|
|
19
|
+
const fileName = path.basename(url);
|
|
20
|
+
const filePath = getFilePathFromURL(url);
|
|
10
21
|
|
|
11
22
|
if (!fs.existsSync(siteSettings.distFolder)) {
|
|
12
23
|
finalDestination = siteSettings.srcFolder;
|
|
@@ -20,29 +31,31 @@ function streamToDestination(gulp, siteSettings, url, fileName) {
|
|
|
20
31
|
if (resp.statusCode !== 200 && resp.statusCode !== 206) {
|
|
21
32
|
throw new Error(`${resp.statusCode} Error while fetching ${fileName}`);
|
|
22
33
|
} else {
|
|
23
|
-
|
|
34
|
+
imagePaths.push(url);
|
|
24
35
|
}
|
|
25
36
|
})
|
|
26
37
|
.pipe(source(fileName))
|
|
27
|
-
.pipe(gulp.dest(`${finalDestination}/resources
|
|
38
|
+
.pipe(gulp.dest(`${finalDestination}/resources/${filePath}`))
|
|
28
39
|
.on('finish', resolve);
|
|
29
40
|
});
|
|
30
41
|
}
|
|
31
42
|
|
|
32
43
|
function replaceImagePath(gulp, siteSettings) {
|
|
33
|
-
|
|
44
|
+
var finalDestination;
|
|
34
45
|
|
|
35
46
|
if (!fs.existsSync(siteSettings.distFolder)) {
|
|
36
47
|
finalDestination = siteSettings.tmpFolder;
|
|
37
48
|
} else {
|
|
38
49
|
finalDestination = siteSettings.distFolder;
|
|
39
|
-
|
|
50
|
+
}
|
|
40
51
|
|
|
41
|
-
|
|
52
|
+
var stream = gulp.src(`${finalDestination}/index.html`);
|
|
42
53
|
|
|
43
|
-
if (
|
|
44
|
-
|
|
45
|
-
|
|
54
|
+
if (imagePaths.length) {
|
|
55
|
+
imagePaths.forEach(function(imagePath) {
|
|
56
|
+
const fileName = path.basename(imagePath);
|
|
57
|
+
const filePath = getFilePathFromURL(imagePath);
|
|
58
|
+
stream = stream.pipe(replace(new RegExp(`"${imagePath}"`, 'gm'), `"/resources/${filePath}/${fileName}"`))
|
|
46
59
|
});
|
|
47
60
|
}
|
|
48
61
|
return stream.pipe(gulp.dest(finalDestination))
|
|
@@ -90,9 +103,8 @@ const parseImageSources = (gulp, siteSettings) => {
|
|
|
90
103
|
module.exports = function(gulp, siteSettings, siteData) {
|
|
91
104
|
return async function() {
|
|
92
105
|
const urls = parseImageSources(gulp, siteSettings);
|
|
93
|
-
const urlsPromises = urls.map(async(url) => {
|
|
94
|
-
|
|
95
|
-
return await streamToDestination(gulp, siteSettings, url, fileName);
|
|
106
|
+
const urlsPromises = urls.map(async (url) => {
|
|
107
|
+
return await streamToDestination(gulp, siteSettings, url);
|
|
96
108
|
});
|
|
97
109
|
|
|
98
110
|
return await Promise.all(urlsPromises).then(function() { // eslint-disable-line no-undef
|
package/gulp-tasks/tasks.js
CHANGED
|
@@ -384,6 +384,18 @@ module.exports = function() {
|
|
|
384
384
|
}
|
|
385
385
|
},
|
|
386
386
|
|
|
387
|
+
// Copy videos
|
|
388
|
+
'copy-videos': {
|
|
389
|
+
subtasks: [],
|
|
390
|
+
func: function(opts) {
|
|
391
|
+
if ('undefined' === typeof opts.gulpTasksFolderPath) {
|
|
392
|
+
opts.gulpTasksFolderPath = '.';
|
|
393
|
+
}
|
|
394
|
+
|
|
395
|
+
return require(opts.gulpTasksFolderPath + '/copy-videos')(opts.gulp, opts.gulpSettings);
|
|
396
|
+
}
|
|
397
|
+
},
|
|
398
|
+
|
|
387
399
|
// Grab theme json file from shared resources
|
|
388
400
|
'grab-theme-json': {
|
|
389
401
|
subtasks: [],
|