mod-build 3.6.20 → 3.6.22-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 +1 -1
- package/gulp-tasks/build.js +1 -1
- package/gulp-tasks/grab-global-images.js +82 -0
- package/gulp-tasks/grab-shared-scripts.js +193 -190
- package/gulp-tasks/tasks.js +12 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/gulp-tasks/build.js
CHANGED
|
@@ -10,7 +10,7 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
|
|
|
10
10
|
if (siteData.isQSPage) {
|
|
11
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'];
|
|
12
12
|
} else {
|
|
13
|
-
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'combine-files', 'grab-images', 'js-lint', 'html-min', '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', 'combine-files', 'grab-images','grab-global-images', 'js-lint', 'html-min', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'grab-tooltips-json', 'build-stat'];
|
|
14
14
|
}
|
|
15
15
|
} else {
|
|
16
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'];
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
var fs = require('fs');
|
|
2
|
+
var request = require('request');
|
|
3
|
+
var source = require('vinyl-source-stream');
|
|
4
|
+
var replace = require('gulp-replace');
|
|
5
|
+
|
|
6
|
+
function streamToDestination(gulp, siteSettings, url, fileName) {
|
|
7
|
+
return new Promise(resolve => { // eslint-disable-line no-undef
|
|
8
|
+
request(url)
|
|
9
|
+
.on('response', resp => {
|
|
10
|
+
if (resp.statusCode !== 200 && resp.statusCode !== 206) {
|
|
11
|
+
throw new Error(`${resp.statusCode} Error while fetching ${fileName}`);
|
|
12
|
+
} else {
|
|
13
|
+
replaceImgSrc(gulp, siteSettings, fileName);
|
|
14
|
+
}
|
|
15
|
+
})
|
|
16
|
+
.pipe(source(fileName))
|
|
17
|
+
.pipe(gulp.dest(`${siteSettings.srcFolder}/resources/images/`))
|
|
18
|
+
.on('finish', resolve);
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function replaceImgSrc(gulp, siteSettings, fileName) {
|
|
23
|
+
const fileRegex = new RegExp(`(https?:\/\/.*${fileName})`, 'gm');
|
|
24
|
+
|
|
25
|
+
return gulp.src(`${siteSettings.tmpFolder}/index.html`)
|
|
26
|
+
.pipe(replace(fileRegex, '/resources/images/' + fileName))
|
|
27
|
+
.pipe(gulp.dest('.'));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const getTags = (string) => {
|
|
31
|
+
const regExs = [/<img.*?src="(.*?)"[^\>]+>/g, /<use.*?href="(.*?)".*?>/g, /<source.*?srcset="(.*?)".*?>/g, /url\('#{\$path}.*?'\)/g];
|
|
32
|
+
let tags = [];
|
|
33
|
+
|
|
34
|
+
regExs.forEach((regEx) => {
|
|
35
|
+
const match = string.match(regEx);
|
|
36
|
+
|
|
37
|
+
if (match) {
|
|
38
|
+
tags = [...tags, ...match];
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
return tags;
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
const getUrls = (tags) => {
|
|
46
|
+
const urls = [];
|
|
47
|
+
|
|
48
|
+
tags.forEach((tag) => {
|
|
49
|
+
if (tag) {
|
|
50
|
+
let url = tag;
|
|
51
|
+
url = url.match(/(https?:\/\/[^\s]+)/gim);
|
|
52
|
+
if (url) {
|
|
53
|
+
url = url[0];
|
|
54
|
+
url = url.replace(/"/g, "")
|
|
55
|
+
urls.push(url)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
return [...new Set(urls)]; // eslint-disable-line no-undef
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const parseImageSources = (gulp, siteSettings) => {
|
|
64
|
+
const text = fs.readFileSync(`${siteSettings.tmpFolder}/index.html`, 'utf8');
|
|
65
|
+
const textMatches = getTags(text);
|
|
66
|
+
return getUrls(textMatches);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
module.exports = function(gulp, siteSettings, siteData) {
|
|
70
|
+
return function() {
|
|
71
|
+
const { isWhiteLabel } = siteData;
|
|
72
|
+
const urls = parseImageSources(gulp, siteSettings);
|
|
73
|
+
const ouputPath = isWhiteLabel ? 'images/' : 'temp/assets/images/';
|
|
74
|
+
const urlsPromises = urls.map((url) => {
|
|
75
|
+
const fileName = url.slice(url.lastIndexOf('/') + 1);
|
|
76
|
+
const relativePath = ouputPath + url.replace(fileName, '');
|
|
77
|
+
return streamToDestination(gulp, siteSettings, url, fileName, relativePath);
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
return Promise.all(urlsPromises); // eslint-disable-line no-undef
|
|
81
|
+
};
|
|
82
|
+
};
|
|
@@ -5,219 +5,222 @@ var hash = require('gulp-hash');
|
|
|
5
5
|
var tap = require('gulp-tap');
|
|
6
6
|
var path = require('path');
|
|
7
7
|
const fileNames = {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
modAlyticsFileName: '',
|
|
9
|
+
modUtilsFileName: '',
|
|
10
|
+
abandonmentJsFileName: '',
|
|
11
|
+
footerComponentJsFileName: '',
|
|
12
|
+
modFooterStylesFileName: '',
|
|
13
|
+
qsFooterStylesFileName: '',
|
|
14
|
+
modFormFileName: '',
|
|
15
|
+
qsFormFileName: ''
|
|
16
|
+
};
|
|
16
17
|
var isQuotePageOrUseRelativePath = false;
|
|
17
18
|
var resourceURL = '';
|
|
18
19
|
function replaceModalyticsSrc(gulp, gulpPlugins, siteSettings, siteData) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
const resourcePath = isQuotePageOrUseRelativePath ? '{{#if this.src}}{{this.src}}{{/if}}resources/scripts/mod-alytics/' : '/resources/scripts/mod-alytics/';
|
|
21
|
+
return gulp.src(siteSettings.srcFolder + '/shared-components/head/head.html')
|
|
22
|
+
.pipe(replace(/".*(modalytics).*"/, resourcePath + fileNames.modAlyticsFileName))
|
|
23
|
+
.pipe(gulp.dest(siteSettings.srcFolder + '/shared-components/head'));
|
|
23
24
|
}
|
|
24
25
|
function replaceFootAssetScripts(gulp, gulpPlugins, siteSettings, siteData) {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
26
|
+
const resourcePath = isQuotePageOrUseRelativePath ? '{{#if this.nodeModulesPath}}{{this.nodeModulesPath}}{{/if}}resources/scripts' : '/resources/scripts';
|
|
27
|
+
return gulp.src(siteSettings.srcFolder + '/shared-components/foot-assets/foot-assets.html')
|
|
28
|
+
.pipe(replace(/"(?:(?!"|js")[\s\S])+(modutils|mod-utils.*?)js"/, resourcePath + '/mod-utils/' + fileNames.modUtilsFileName))
|
|
29
|
+
.pipe(replace(/"(?:(?!"|")[\s\S])+(footer\/footer-component.*?)js"/, resourcePath + '/footer/' + fileNames.footerComponentJsFileName))
|
|
30
|
+
.pipe(replace(/"(?:(?!"|")[\s\S])+(mod-form\/mod-form.*?)js"/, resourcePath + '/mod-form/' + fileNames.modFormFileName))
|
|
31
|
+
.pipe(replace(/"(?:(?!"|")[\s\S])+(qs-form.*?)js"/, resourcePath + '/mod-form/' + fileNames.qsFormFileName))
|
|
32
|
+
.pipe(gulp.dest(siteSettings.srcFolder + '/shared-components/foot-assets'));
|
|
32
33
|
}
|
|
33
34
|
function replaceAbandonmentJsSrc(gulp, gulpPlugins, siteSettings, siteData) {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
35
|
+
const resourcePath = isQuotePageOrUseRelativePath ? 'resources/scripts/abandonment/' : '/resources/scripts/abandonment/';
|
|
36
|
+
return gulp.src(siteSettings.srcFolder + '/templates/abandonment/*.html')
|
|
37
|
+
.pipe(replace(/"(?:(?!"|")[\s\S])+(abandonment\/abandonment.*?)js"/, resourcePath + fileNames.abandonmentJsFileName))
|
|
38
|
+
.pipe(gulp.dest(siteSettings.srcFolder + '/templates/abandonment'));
|
|
38
39
|
}
|
|
39
40
|
function replaceFooterStylesReference(gulp, gulpPlugins, siteSettings, siteData) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
41
|
+
if (siteData.siteData && siteData.siteData.useRelativePathForResources === true) {
|
|
42
|
+
return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/' + fileNames.footerComponentJsFileName)
|
|
43
|
+
.pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/mod.*?)\)/, 'concat("resources/styles/components/footer/' + fileNames.modFooterStylesFileName + '")'))
|
|
44
|
+
.pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/qs.*?)\)/, 'concat("resources/styles/components/footer/' + fileNames.qsFooterStylesFileName + '")'))
|
|
45
|
+
.pipe(gulp.dest(siteSettings.srcFolder + '/resources/scripts/footer'))
|
|
46
|
+
} else if (!siteData.siteData || siteData.siteData && !siteData.siteData.isQuotePage) {
|
|
47
|
+
return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/' + fileNames.footerComponentJsFileName)
|
|
48
|
+
.pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/mod.*?)\)/, 'concat("/resources/styles/components/footer/' + fileNames.modFooterStylesFileName + '")'))
|
|
49
|
+
.pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/qs.*?)\)/, 'concat("/resources/styles/components/footer/' + fileNames.qsFooterStylesFileName + '")'))
|
|
50
|
+
.pipe(gulp.dest(siteSettings.srcFolder + '/resources/scripts/footer'))
|
|
51
|
+
}
|
|
51
52
|
}
|
|
52
53
|
function replaceFooterStylesReferenceInMap(gulp, gulpPlugins, siteSettings, siteData) {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
54
|
+
if (siteData.siteData && siteData.siteData.useRelativePathForResources === true) {
|
|
55
|
+
return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/footer-component.min.js.map')
|
|
56
|
+
.pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/mod.*?)\`/, '`resources/styles/components/footer/' + fileNames.modFooterStylesFileName + '`'))
|
|
57
|
+
.pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/mod.*?)\`/, '`resources/styles/components/footer/' + fileNames.qsFooterStylesFileName + '`'))
|
|
58
|
+
.pipe(gulp.dest(siteSettings.srcFolder + '/resources/scripts/footer'));
|
|
59
|
+
} else if (!siteData.siteData || siteData.siteData && !siteData.siteData.isQuotePage) {
|
|
60
|
+
return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/footer-component.min.js.map')
|
|
61
|
+
.pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/mod.*?)\`/, '`/resources/styles/components/footer/' + fileNames.modFooterStylesFileName + '`'))
|
|
62
|
+
.pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/mod.*?)\`/, '`/resources/styles/components/footer/' + fileNames.qsFooterStylesFileName + '`'))
|
|
63
|
+
.pipe(gulp.dest(siteSettings.srcFolder + '/resources/scripts/footer'));
|
|
64
|
+
}
|
|
64
65
|
}
|
|
65
66
|
function getFileFromURL(url) {
|
|
66
|
-
|
|
67
|
+
return url.split('/').pop();
|
|
67
68
|
}
|
|
68
69
|
function getResource(url, config = {}, fn, fnArray) {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
70
|
+
if (Object.keys(config).length === 0) {
|
|
71
|
+
return false;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
return new Promise(resolve => {
|
|
72
75
|
const file = getFileFromURL(url);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
})
|
|
76
|
+
request(`${resourceURL}/${url}`)
|
|
77
|
+
.on('response', resp => {
|
|
78
|
+
if (resp.statusCode !== 200) {
|
|
79
|
+
throw new Error(`${resp.statusCode} Error while fetching ${file}`);
|
|
80
|
+
}
|
|
81
|
+
})
|
|
82
|
+
.pipe(source(`${file}`))
|
|
83
|
+
.pipe(hash({
|
|
84
|
+
hashLength: 20,
|
|
85
|
+
template: file.replace(/^([^.]*)\.(.*)$/, '$1-<%= hash %>.$2')
|
|
86
|
+
}))
|
|
87
|
+
.pipe(tap(function(file, t) {
|
|
88
|
+
fileNames[config.fileName] = path.basename(file.path);
|
|
89
|
+
}))
|
|
90
|
+
.pipe(config.gulp.dest(`${config.siteSettings.srcFolder}/resources/${config.dest}`))
|
|
91
|
+
.on('finish', resolve);
|
|
92
|
+
})
|
|
91
93
|
.then(() => {
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
94
|
+
if (!config.mapUrl) { return false };
|
|
95
|
+
const file = getFileFromURL(config.mapUrl);
|
|
96
|
+
return new Promise((resolve) => {
|
|
97
|
+
request(`${resourceURL}/${config.mapUrl}`)
|
|
98
|
+
.on('response', (resp) => {
|
|
99
|
+
if (resp.statusCode !== 200) {
|
|
100
|
+
throw new Error(`${resp.statusCode} Error while fetching ${file}`);
|
|
101
|
+
} else {
|
|
102
|
+
if (typeof fn === 'function') {
|
|
103
|
+
fn.call(null, config.gulp, config.gulpSettings, config.siteSettings, config.siteData);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
})
|
|
107
|
+
.pipe(source(`${file}`))
|
|
108
|
+
.pipe(config.gulp.dest(`${config.siteSettings.srcFolder}/resources/${config.dest}`))
|
|
109
|
+
.on('finish', resolve);
|
|
110
|
+
});
|
|
108
111
|
})
|
|
109
112
|
.then(() => {
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
113
|
+
if (fnArray && fnArray.length) {
|
|
114
|
+
fnArray.map(function(fn) {
|
|
115
|
+
if (typeof fn === 'function') {
|
|
116
|
+
fn.call(null, config.gulp, config.gulpSettings, config.siteSettings, config.siteData)
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}
|
|
117
120
|
});
|
|
118
121
|
}
|
|
119
122
|
const TASKS = {
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
123
|
+
copyModalytics: {
|
|
124
|
+
url: `mod-alytics/modalytics.min.js`,
|
|
125
|
+
config: {
|
|
126
|
+
fileName: 'modAlyticsFileName',
|
|
127
|
+
dest: 'scripts/mod-alytics',
|
|
128
|
+
mapUrl: `mod-alytics/modalytics.min.js.map`,
|
|
129
|
+
},
|
|
130
|
+
srcReplaceFn: replaceModalyticsSrc,
|
|
131
|
+
additionalSrcReplaceFns: []
|
|
132
|
+
},
|
|
133
|
+
copyModutils: {
|
|
134
|
+
url: `mod-utils/modutils.min.js`,
|
|
135
|
+
config: {
|
|
136
|
+
fileName: 'modUtilsFileName',
|
|
137
|
+
dest: 'scripts/mod-utils',
|
|
138
|
+
mapUrl: `mod-utils/modutils.min.js.map`,
|
|
139
|
+
},
|
|
140
|
+
srcReplaceFn: null,
|
|
141
|
+
additionalSrcReplaceFns: []
|
|
142
|
+
},
|
|
143
|
+
copyAbandonmentJs: {
|
|
144
|
+
url: `shared-resources/scripts/abandonment/abandonment.min.js`,
|
|
145
|
+
config: {
|
|
146
|
+
fileName: 'abandonmentJsFileName',
|
|
147
|
+
dest: 'scripts/abandonment',
|
|
148
|
+
mapUrl: `shared-resources/scripts/abandonment/abandonment.min.js.map`,
|
|
149
|
+
},
|
|
150
|
+
srcReplaceFn: replaceAbandonmentJsSrc,
|
|
151
|
+
additionalSrcReplaceFns: []
|
|
152
|
+
},
|
|
153
|
+
copyFooterComponentJs: {
|
|
154
|
+
url: `shared-resources/scripts/footer/footer-component.min.js`,
|
|
155
|
+
config: {
|
|
156
|
+
fileName: 'footerComponentJsFileName',
|
|
157
|
+
dest: 'scripts/footer',
|
|
158
|
+
mapUrl: `shared-resources/scripts/footer/footer-component.min.js.map`,
|
|
159
|
+
},
|
|
160
|
+
srcReplaceFn: null,
|
|
161
|
+
additionalSrcReplaceFns: []
|
|
162
|
+
},
|
|
163
|
+
copyModForm: {
|
|
164
|
+
url: `mod-form/mod-form.min.js`,
|
|
165
|
+
config: {
|
|
166
|
+
fileName: 'modFormFileName',
|
|
167
|
+
dest: 'scripts/mod-form',
|
|
168
|
+
mapUrl: `mod-form/mod-form.min.js.map`,
|
|
169
|
+
},
|
|
170
|
+
srcReplaceFn: null,
|
|
171
|
+
additionalSrcReplaceFns: []
|
|
172
|
+
},
|
|
173
|
+
copyQsForm: {
|
|
174
|
+
url: `mod-form/qs-form.min.js`,
|
|
175
|
+
config: {
|
|
176
|
+
fileName: 'qsFormFileName',
|
|
177
|
+
dest: 'scripts/mod-form',
|
|
178
|
+
mapUrl: `mod-form/qs-form.min.js.map`,
|
|
179
|
+
},
|
|
180
|
+
srcReplaceFn: replaceFootAssetScripts,
|
|
181
|
+
additionalSrcReplaceFns: []
|
|
182
|
+
},
|
|
183
|
+
copyModFooterComponentStyles: {
|
|
184
|
+
url: `shared-resources/styles/components/footer/mod-footer.min.css`,
|
|
185
|
+
config: {
|
|
186
|
+
fileName: 'modFooterStylesFileName',
|
|
187
|
+
dest: 'styles/components/footer',
|
|
188
|
+
mapUrl: null,
|
|
189
|
+
},
|
|
190
|
+
srcReplaceFn: null,
|
|
191
|
+
additionalSrcReplaceFns: [replaceFooterStylesReference, replaceFooterStylesReferenceInMap]
|
|
192
|
+
},
|
|
193
|
+
copyQsFooterComponentStyles: {
|
|
194
|
+
url: `shared-resources/styles/components/footer/qs-footer.min.css`,
|
|
195
|
+
config: {
|
|
196
|
+
fileName: 'qsFooterStylesFileName',
|
|
197
|
+
dest: 'styles/components/footer',
|
|
198
|
+
mapUrl: null,
|
|
199
|
+
},
|
|
200
|
+
srcReplaceFn: null,
|
|
201
|
+
additionalSrcReplaceFns: [replaceFooterStylesReference, replaceFooterStylesReferenceInMap]
|
|
202
|
+
}
|
|
200
203
|
};
|
|
201
204
|
module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
205
|
+
const isQuotePage = siteData.siteData && siteData.siteData.isQuotePage || siteData && siteData.isQuotePage;
|
|
206
|
+
const useRelativePathForResources = siteData.siteData && siteData.siteData.useRelativePathForResources || siteData && siteData.useRelativePathForResources;
|
|
207
|
+
isQuotePageOrUseRelativePath = isQuotePage === true || useRelativePathForResources === true;
|
|
208
|
+
resourceURL = `https://${siteSettings.nodeEnv}/quote/resources`;
|
|
209
|
+
return function() {
|
|
210
|
+
const { nodeEnv } = siteSettings;
|
|
211
|
+
if (!nodeEnv) {
|
|
212
|
+
throw new Error('Missing environment variables. Did you start with gulp instead of npm run...?');
|
|
213
|
+
}
|
|
214
|
+
return (function() {
|
|
215
|
+
const tasks = Object.values(TASKS)
|
|
216
|
+
if (tasks.length) {
|
|
217
|
+
var getAllResources = tasks.map(function(task) {
|
|
218
|
+
Object.assign(task.config, { gulp, gulpPlugins, siteSettings, siteData });
|
|
219
|
+
return getResource(task.url, task.config, task.srcReplaceFn, task.additionalSrcReplaceFns)
|
|
220
|
+
});
|
|
221
|
+
}
|
|
219
222
|
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
+
return Promise.all(getAllResources);
|
|
224
|
+
}());
|
|
225
|
+
};
|
|
223
226
|
};
|
package/gulp-tasks/tasks.js
CHANGED
|
@@ -346,6 +346,18 @@ module.exports = function() {
|
|
|
346
346
|
|
|
347
347
|
return require(opts.gulpTasksFolderPath + '/grab-images')(opts.gulp, opts.gulpSettings, opts.siteData);
|
|
348
348
|
}
|
|
349
|
+
},
|
|
350
|
+
|
|
351
|
+
// Get global images
|
|
352
|
+
'grab-global-images': {
|
|
353
|
+
subtasks: [],
|
|
354
|
+
func: function(opts) {
|
|
355
|
+
if ('undefined' === typeof opts.gulpTasksFolderPath) {
|
|
356
|
+
opts.gulpTasksFolderPath = '.';
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
return require(opts.gulpTasksFolderPath + '/grab-global-images')(opts.gulp, opts.gulpSettings, opts.siteData);
|
|
360
|
+
}
|
|
349
361
|
},
|
|
350
362
|
|
|
351
363
|
// Copy json files to dist
|