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 CHANGED
@@ -1,6 +1,6 @@
1
1
  # Changelog
2
2
 
3
- ## 3.6.15 & 3.6.16 & 3.6.17 & 3.6.18
3
+ ## 3.6.21
4
4
 
5
5
  - `grab-shared-scripts` task code refactoring changes.
6
6
 
@@ -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
- modAlyticsFileName: '',
9
- modUtilsFileName: '',
10
- abandonmentJsFileName: '',
11
- footerComponentJsFileName: '',
12
- modFooterStylesFileName: '',
13
- qsFooterStylesFileName: '',
14
- modFormFileName: '',
15
- qsFormFileName: ''};
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
- const resourcePath = isQuotePageOrUseRelativePath ? '{{#if this.src}}{{this.src}}{{/if}}resources/scripts/mod-alytics/' : '/resources/scripts/mod-alytics/';
20
- return gulp.src(siteSettings.srcFolder + '/shared-components/head/head.html')
21
- .pipe(replace(/".*(modalytics).*"/, resourcePath + fileNames.modAlyticsFileName))
22
- .pipe(gulp.dest(siteSettings.srcFolder + '/shared-components/head'));
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
- const resourcePath = isQuotePageOrUseRelativePath ? '{{#if this.nodeModulesPath}}{{this.nodeModulesPath}}{{/if}}resources/scripts' : '/resources/scripts';
26
- return gulp.src(siteSettings.srcFolder + '/shared-components/foot-assets/foot-assets.html')
27
- .pipe(replace(/"(?:(?!"|js")[\s\S])+(modutils|mod-utils.*?)js"/, resourcePath + '/mod-utils/' + fileNames.modUtilsFileName))
28
- .pipe(replace(/"(?:(?!"|")[\s\S])+(footer\/footer-component.*?)js"/, resourcePath + '/footer/' + fileNames.footerComponentJsFileName))
29
- .pipe(replace(/"(?:(?!"|")[\s\S])+(mod-form\/mod-form.*?)js"/, resourcePath + '/mod-form/' + fileNames.modFormFileName))
30
- .pipe(replace(/"(?:(?!"|")[\s\S])+(qs-form.*?)js"/, resourcePath + '/mod-form/' + fileNames.qsFormFileName))
31
- .pipe(gulp.dest(siteSettings.srcFolder + '/shared-components/foot-assets'));
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
- const resourcePath = isQuotePageOrUseRelativePath ? 'resources/scripts/abandonment/' : '/resources/scripts/abandonment/';
35
- return gulp.src(siteSettings.srcFolder + '/templates/abandonment/*.html')
36
- .pipe(replace(/"(?:(?!"|")[\s\S])+(abandonment\/abandonment.*?)js"/, resourcePath + fileNames.abandonmentJsFileName))
37
- .pipe(gulp.dest(siteSettings.srcFolder + '/templates/abandonment'));
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
- if (siteData.siteData && siteData.siteData.useRelativePathForResources === true) {
41
- return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/' + fileNames.footerComponentJsFileName)
42
- .pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/mod.*?)\)/, 'concat("resources/styles/components/footer/' + fileNames.modFooterStylesFileName + '")'))
43
- .pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/qs.*?)\)/, 'concat("resources/styles/components/footer/' + fileNames.qsFooterStylesFileName + '")'))
44
- .pipe(gulp.dest(siteSettings.srcFolder + '/resources/scripts/footer'))
45
- } else if (!siteData.siteData || siteData.siteData && !siteData.siteData.isQuotePage) {
46
- return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/' + fileNames.footerComponentJsFileName)
47
- .pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/mod.*?)\)/, 'concat("/resources/styles/components/footer/' + fileNames.modFooterStylesFileName + '")'))
48
- .pipe(replace(/concat\((?:(?!concat\(|\))[\s\S])+(components\/footer\/qs.*?)\)/, 'concat("/resources/styles/components/footer/' + fileNames.qsFooterStylesFileName + '")'))
49
- .pipe(gulp.dest(siteSettings.srcFolder + '/resources/scripts/footer'))
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
- if (siteData.siteData && siteData.siteData.useRelativePathForResources === true) {
54
- return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/footer-component.min.js.map')
55
- .pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/mod.*?)\`/, '`resources/styles/components/footer/' + fileNames.modFooterStylesFileName + '`'))
56
- .pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/mod.*?)\`/, '`resources/styles/components/footer/' + fileNames.qsFooterStylesFileName + '`'))
57
- .pipe(gulp.dest(siteSettings.srcFolder + '/resources/scripts/footer'));
58
- } else if (!siteData.siteData || siteData.siteData && !siteData.siteData.isQuotePage) {
59
- return gulp.src(siteSettings.srcFolder + '/resources/scripts/footer/footer-component.min.js.map')
60
- .pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/mod.*?)\`/, '`/resources/styles/components/footer/' + fileNames.modFooterStylesFileName + '`'))
61
- .pipe(replace(/\`(?:(?!\`|\`)[\s\S])+(components\/footer\/mod.*?)\`/, '`/resources/styles/components/footer/' + fileNames.qsFooterStylesFileName + '`'))
62
- .pipe(gulp.dest(siteSettings.srcFolder + '/resources/scripts/footer'));
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
- return url.split('/').pop();
67
+ return url.split('/').pop();
67
68
  }
68
69
  function getResource(url, config = {}, fn, fnArray) {
69
- if (Object.keys(config).length === 0) {
70
- return false;
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
- return new Promise(resolve => {
74
- request(`${resourceURL}/${url}`)
75
- .on('response', resp => {
76
- if (resp.statusCode !== 200) {
77
- throw new Error(`${resp.statusCode} Error while fetching ${file}`);
78
- }
79
- })
80
- .pipe(source(`${file}`))
81
- .pipe(hash({
82
- hashLength: 20,
83
- template: file.replace(/^([^.]*)\.(.*)$/, '$1-<%= hash %>.$2')
84
- }))
85
- .pipe(tap(function(file, t){
86
- fileNames[config.fileName] = path.basename(file.path);
87
- }))
88
- .pipe(config.gulp.dest(`${config.siteSettings.srcFolder}/resources/${config.dest}`))
89
- .on('finish', resolve);
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
- if (!config.mapUrl) { return false };
93
- return new Promise((resolve) => {
94
- request(`${resourceURL}/${url}`)
95
- .on('response', (resp) => {
96
- if (resp.statusCode !== 200) {
97
- throw new Error(`${resp.statusCode} Error while fetching ${file}`);
98
- } else {
99
- if (typeof fn === 'function') {
100
- fn.call(null, config.gulp, config.gulpSettings, config.siteSettings, config.siteData);
101
- }
102
- }
103
- })
104
- .pipe(source(`${file}`))
105
- .pipe(config.gulp.dest(`${config.siteSettings.srcFolder}/resources/${config.dest}`))
106
- .on('finish', resolve);
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
- if (fnArray && fnArray.length) {
111
- fnArray.map(function(fn) {
112
- if (typeof fn === 'function') {
113
- fn.call(null, config.gulp, config.gulpSettings, config.siteSettings, config.siteData)
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
- copyModalytics: {
121
- url: `mod-alytics/modalytics.min.js`,
122
- config: {
123
- fileName: 'modAlyticsFileName',
124
- dest: 'scripts/mod-alytics',
125
- mapUrl: `mod-alytics/modalytics.min.js.map`,
126
- },
127
- srcReplaceFn: replaceModalyticsSrc,
128
- additionalSrcReplaceFns: []
129
- },
130
- copyModutils: {
131
- url: `mod-utils/modutils.min.js`,
132
- config: {
133
- fileName: 'modUtilsFileName',
134
- dest: 'scripts/mod-utils',
135
- mapUrl: `mod-utils/modutils.min.js.map`,
136
- },
137
- srcReplaceFn: null,
138
- additionalSrcReplaceFns: []
139
- },
140
- copyAbandonmentJs: {
141
- url: `shared-resources/scripts/abandonment/abandonment.min.js`,
142
- config: {
143
- fileName: 'abandonmentJsFileName',
144
- dest: 'scripts/abandonment',
145
- mapUrl: `shared-resources/scripts/abandonment/abandonment.min.js.map`,
146
- },
147
- srcReplaceFn: replaceAbandonmentJsSrc,
148
- additionalSrcReplaceFns: []
149
- },
150
- copyFooterComponentJs: {
151
- url: `shared-resources/scripts/footer/footer-component.min.js`,
152
- config: {
153
- fileName: 'footerComponentJsFileName',
154
- dest: 'scripts/footer',
155
- mapUrl: `shared-resources/scripts/footer/footer-component.min.js.map`,
156
- },
157
- srcReplaceFn: null,
158
- additionalSrcReplaceFns: []
159
- },
160
- copyModForm: {
161
- url: `mod-form/mod-form.min.js`,
162
- config: {
163
- fileName: 'modFormFileName',
164
- dest: 'scripts/mod-form',
165
- mapUrl: `mod-form/mod-form.min.js.map`,
166
- },
167
- srcReplaceFn: null,
168
- additionalSrcReplaceFns: []
169
- },
170
- copyQsForm: {
171
- url: `mod-form/qs-form.min.js`,
172
- config: {
173
- fileName: 'qsFormFileName',
174
- dest: 'scripts/mod-form',
175
- mapUrl: `mod-form/qs-form.min.js.map`,
176
- },
177
- srcReplaceFn: replaceFootAssetScripts,
178
- additionalSrcReplaceFns: []
179
- },
180
- copyModFooterComponentStyles: {
181
- url: `shared-resources/styles/components/footer/mod-footer.min.css`,
182
- config: {
183
- fileName: 'modFooterStylesFileName',
184
- dest: 'styles/components/footer',
185
- mapUrl: null,
186
- },
187
- srcReplaceFn: null,
188
- additionalSrcReplaceFns: [replaceFooterStylesReference, replaceFooterStylesReferenceInMap]
189
- },
190
- copyQsFooterComponentStyles: {
191
- url: `shared-resources/styles/components/footer/qs-footer.min.css`,
192
- config: {
193
- fileName: 'qsFooterStylesFileName',
194
- dest: 'styles/components/footer',
195
- mapUrl: null,
196
- },
197
- srcReplaceFn: null,
198
- additionalSrcReplaceFns: [replaceFooterStylesReference, replaceFooterStylesReferenceInMap]
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
- const isQuotePage = siteData.siteData && siteData.siteData.isQuotePage || siteData && siteData.isQuotePage;
203
- const useRelativePathForResources = siteData.siteData && siteData.siteData.useRelativePathForResources || siteData && siteData.useRelativePathForResources;
204
- isQuotePageOrUseRelativePath = isQuotePage === true || useRelativePathForResources === true;
205
- resourceURL = `https://${siteSettings.nodeEnv}/quote/resources`;
206
- return function() {
207
- const { nodeEnv } = siteSettings;
208
- if (!nodeEnv) {
209
- throw new Error('Missing environment variables. Did you start with gulp instead of npm run...?');
210
- }
211
- return (function() {
212
- const tasks = Object.values(TASKS)
213
- if (tasks.length) {
214
- var getAllResources = tasks.map(function(task) {
215
- Object.assign(task.config, { gulp, gulpPlugins, siteSettings, siteData });
216
- return getResource(task.url, task.config, task.srcReplaceFn, task.additionalSrcReplaceFns)
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
- return Promise.all(getAllResources);
221
- }());
222
- };
223
+ return Promise.all(getAllResources);
224
+ }());
225
+ };
223
226
  };
@@ -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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mod-build",
3
- "version": "3.6.20",
3
+ "version": "3.6.22-beta.1",
4
4
  "description": "Share components for S3 sites.",
5
5
  "scripts": {
6
6
  "test": "echo \"Error: no test specified\" && exit 1"