mod-build 3.6.3 → 3.6.4--beta.10
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 +4 -4
- package/gulp-tasks/cache-bust.js +2 -2
- package/gulp-tasks/grab-shared-scripts.js +68 -0
- package/gulp-tasks/js-lint.js +1 -0
- package/gulp-tasks/serve.js +3 -3
- package/gulp-tasks/tasks.js +15 -1
- package/package.json +1 -1
- package/src/templates/_partials/scripts/analytics.html +9 -6
- package/src/templates/_partials/scripts/vwo-redirect-callback.html +12 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.6.5
|
|
4
|
+
|
|
5
|
+
- Adding a new `grab-shared-scripts` gulp task grab the most recent version from `mod-analytics`. It will copy this version into the site's `resources/scripts/mod-alytics` folder & then update the src in the `head` shared component. Also updated `cache-bust` to ignore this file on build.
|
|
6
|
+
|
|
3
7
|
## 3.6.3
|
|
4
8
|
|
|
5
9
|
- Updating `cache-bust` gulp task to use dashes instead of a period. For example, cached files will now be `home-51fbcbac.js` instead of `home.51fbcbac.js`
|
package/gulp-tasks/build.js
CHANGED
|
@@ -5,15 +5,15 @@ module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
|
|
|
5
5
|
var sequenceOpts;
|
|
6
6
|
|
|
7
7
|
if (siteData.useTypescript) {
|
|
8
|
-
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'templates', 'styles', 'compile-prod', 'js-lint', 'html-min', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'build-stat'];
|
|
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', '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', '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', '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', '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
|
-
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', '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', '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() {
|
package/gulp-tasks/cache-bust.js
CHANGED
|
@@ -3,8 +3,8 @@ module.exports = function(gulp, gulpPlugins, siteSettings) {
|
|
|
3
3
|
return function() {
|
|
4
4
|
return gulp.src(siteSettings.distFolder + '/**')
|
|
5
5
|
.pipe(gulpPlugins.revAll.revision({
|
|
6
|
-
dontRenameFile: [/^\/favicon.ico$/g, '.html', '.txt', /modlogo([\w|\s|-])*\.(?:svg)/g],
|
|
7
|
-
dontUpdateReference: [/^\/favicon.ico$/g, '.html', '.txt', /modlogo([\w|\s|-])*\.(?:svg)/g],
|
|
6
|
+
dontRenameFile: [/^\/favicon.ico$/g, '.html', '.txt', /modlogo([\w|\s|-])*\.(?:svg)/g, /.*modalytics.*/],
|
|
7
|
+
dontUpdateReference: [/^\/favicon.ico$/g, '.html', '.txt', /modlogo([\w|\s|-])*\.(?:svg)/g, /.*modalytics.*/],
|
|
8
8
|
transformFilename: function (file, hash) {
|
|
9
9
|
var ext = path.extname(file.path);
|
|
10
10
|
return path.basename(file.path, ext) + '-' + hash.substr(0, 8) + ext;
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
var request = require('request');
|
|
2
|
+
var source = require('vinyl-source-stream');
|
|
3
|
+
var replace = require('gulp-replace');
|
|
4
|
+
|
|
5
|
+
function replaceModalyticsSrcInHead(gulp, gulpPlugins, siteSettings, siteData, result) {
|
|
6
|
+
if (siteData.siteData && siteData.siteData.isQuotePage === true) {
|
|
7
|
+
return gulp.src(siteSettings.srcFolder + '/shared-components/head/head.html')
|
|
8
|
+
.pipe(replace(/".*(modalytics).*"/, `"resources/scripts/mod-alytics/${result}"`))
|
|
9
|
+
.pipe(gulp.dest(siteSettings.srcFolder + '/shared-components/head'));
|
|
10
|
+
} else {
|
|
11
|
+
return gulp.src(siteSettings.srcFolder + '/shared-components/head/head.html')
|
|
12
|
+
.pipe(replace(/".*(modalytics).*"/, `"/resources/scripts/mod-alytics/${result}"`))
|
|
13
|
+
.pipe(gulp.dest(siteSettings.srcFolder + '/shared-components/head'));
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function copyCurrentModalytics(gulp, gulpPlugins, siteSettings, siteData) {
|
|
18
|
+
return new Promise(resolve => {
|
|
19
|
+
request(`https://${siteSettings.nodeEnv}/quote/resources/mod-alytics/mod-alytics-version.txt`, function(err, resp, body) {
|
|
20
|
+
if (resp.statusCode !== 200) {
|
|
21
|
+
throw new Error(`${resp.statusCode}: Error while fetching mod-alytics-version.txt`);
|
|
22
|
+
}
|
|
23
|
+
resolve(body.replace(/\s+/g, ''));
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
})
|
|
27
|
+
.then((result) => {
|
|
28
|
+
// copy over main file
|
|
29
|
+
return new Promise(resolve => {
|
|
30
|
+
request(`https://${siteSettings.nodeEnv}/quote/resources/mod-alytics/${result}`)
|
|
31
|
+
.on('response', resp => {
|
|
32
|
+
if (resp.statusCode !== 200) {
|
|
33
|
+
throw new Error(`${resp.statusCode} Error while fetching ${result}`);
|
|
34
|
+
} else {
|
|
35
|
+
replaceModalyticsSrcInHead(gulp, gulpPlugins, siteSettings, siteData, result);
|
|
36
|
+
}
|
|
37
|
+
})
|
|
38
|
+
.pipe(source(result))
|
|
39
|
+
.pipe(gulp.dest(`${siteSettings.srcFolder}/resources/scripts/mod-alytics`))
|
|
40
|
+
resolve(result)
|
|
41
|
+
});
|
|
42
|
+
})
|
|
43
|
+
.then((result) => {
|
|
44
|
+
// copy over source map
|
|
45
|
+
return new Promise(resolve => {
|
|
46
|
+
request(`https://${siteSettings.nodeEnv}/quote/resources/mod-alytics/${result}.map`)
|
|
47
|
+
.on('response', resp => {
|
|
48
|
+
if (resp.statusCode !== 200) {
|
|
49
|
+
throw new Error(`${resp.statusCode} Error while fetching ${result}`);
|
|
50
|
+
}
|
|
51
|
+
})
|
|
52
|
+
.pipe(source(`${result}.map`))
|
|
53
|
+
.pipe(gulp.dest(`${siteSettings.srcFolder}/resources/scripts/mod-alytics`))
|
|
54
|
+
.on('finish', resolve);
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
|
|
60
|
+
return function() {
|
|
61
|
+
const { nodeEnv } = siteSettings;
|
|
62
|
+
if (!nodeEnv) {
|
|
63
|
+
throw new Error('Missing environment variables. Did you start with gulp instead of npm run...?');
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return copyCurrentModalytics(gulp, gulpPlugins, siteSettings, siteData);
|
|
67
|
+
};
|
|
68
|
+
};
|
package/gulp-tasks/js-lint.js
CHANGED
|
@@ -14,6 +14,7 @@ module.exports = function(gulp, gulpPlugins, siteSettings) {
|
|
|
14
14
|
'gulpfile.babel.js',
|
|
15
15
|
'gulp-tasks/*.js',
|
|
16
16
|
'!' + siteSettings.srcFolder + '/' + siteSettings.scriptsSubfolder + '/vendor/**/*.js', // do not lint 3rd party scripts,
|
|
17
|
+
'!' + siteSettings.srcFolder + '/' + siteSettings.scriptsSubfolder + '/resources/**/*.js', // do not lint copied shared resource scripts,
|
|
17
18
|
'!' + siteSettings.srcFolder + '/' + siteSettings.scriptsCompiledFolder + '**/*.js' // do not lint compiled scripts
|
|
18
19
|
])
|
|
19
20
|
.pipe(gulpPlugins.eslint(siteSettings.jsLint))
|
package/gulp-tasks/serve.js
CHANGED
|
@@ -4,11 +4,11 @@ module.exports.src = function(gulp, gulpPlugins, siteSettings, siteData) {
|
|
|
4
4
|
var runSequence = require('run-sequence');
|
|
5
5
|
var sequenceOpts;
|
|
6
6
|
if (siteData.useTypescript) {
|
|
7
|
-
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'templates', 'styles', 'compile', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
|
|
7
|
+
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'compile', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
|
|
8
8
|
} else if (siteData.isQSPage) {
|
|
9
|
-
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'templates', 'styles', 'grab-theme-json', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
|
|
9
|
+
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'grab-theme-json', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
|
|
10
10
|
} else {
|
|
11
|
-
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'templates', 'styles', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
|
|
11
|
+
sequenceOpts = ['clean', 'grab-cdn', 'grab-shared-components', 'grab-shared-scripts', 'templates', 'styles', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
|
|
12
12
|
}
|
|
13
13
|
runSequence(...sequenceOpts, () => {
|
|
14
14
|
// Run a BrowserSync server
|
package/gulp-tasks/tasks.js
CHANGED
|
@@ -42,7 +42,7 @@ module.exports = function() {
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
|
|
45
|
-
// Grab component
|
|
45
|
+
// Grab component files from CDN so they can be swapped into build
|
|
46
46
|
'grab-shared-components': {
|
|
47
47
|
subtasks: [],
|
|
48
48
|
func: function(opts) {
|
|
@@ -56,6 +56,20 @@ module.exports = function() {
|
|
|
56
56
|
}
|
|
57
57
|
},
|
|
58
58
|
|
|
59
|
+
// Grab shared scripts from CDN so they can swapped into build
|
|
60
|
+
'grab-shared-scripts': {
|
|
61
|
+
subtasks: [],
|
|
62
|
+
func: function(opts) {
|
|
63
|
+
if ('undefined' === typeof opts.gulpTasksFolderPath) {
|
|
64
|
+
opts.gulpTasksFolderPath = '.';
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (opts.siteData.useCDN) {
|
|
68
|
+
return require(opts.gulpTasksFolderPath + '/grab-shared-scripts')(opts.gulp, opts.gulpPlugins, opts.gulpSettings, opts.siteData);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
},
|
|
72
|
+
|
|
59
73
|
// Link scss files
|
|
60
74
|
'sass-lint': {
|
|
61
75
|
subtasks: [],
|
package/package.json
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
<script>
|
|
2
2
|
{{ fileInclude 'node_modules/mod-build/src/scripts/has-qs-params.js' }}
|
|
3
3
|
{{ fileInclude 'node_modules/mod-build/src/scripts/url-cleaner.js' }}
|
|
4
|
-
{{
|
|
5
|
-
|
|
6
|
-
Modalytics
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
{{#unless noheap}}
|
|
5
|
+
{{ fileInclude 'node_modules/mod-build/src/scripts/vendor/heap-tracking.js' }}
|
|
6
|
+
if(window.Modalytics) {
|
|
7
|
+
Modalytics.init();
|
|
8
|
+
} else {
|
|
9
|
+
{{ fileInclude 'node_modules/mod-build/src/scripts/vendor/heap-addeventproperties-identify.js' }}
|
|
10
|
+
}
|
|
11
|
+
{{/unless}}
|
|
12
|
+
|
|
10
13
|
{{#unless nogtm}}
|
|
11
14
|
{{ fileInclude 'node_modules/mod-build/src/scripts/vendor/google-tag-manager-head.js' }}
|
|
12
15
|
{{/unless}}
|
|
@@ -30,13 +30,18 @@
|
|
|
30
30
|
if (!window.willRedirectionOccurByVWO) {
|
|
31
31
|
clearTimeout(hardLimitTimer);
|
|
32
32
|
try {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
{{ fileInclude 'node_modules/mod-build/src/scripts/vendor/heap-
|
|
39
|
-
|
|
33
|
+
// flag to call Modalytics.initHeapVwo() method in site level js
|
|
34
|
+
window.initHeapVwo = true;
|
|
35
|
+
|
|
36
|
+
{{#unless noheap}}
|
|
37
|
+
{{ fileInclude 'node_modules/mod-build/src/scripts/vendor/heap-tracking.js' }}
|
|
38
|
+
{{ fileInclude 'node_modules/mod-build/src/scripts/vendor/heap-vwo.js' }}
|
|
39
|
+
if(window.Modalytics) {
|
|
40
|
+
Modalytics.init();
|
|
41
|
+
} else {
|
|
42
|
+
{{ fileInclude 'node_modules/mod-build/src/scripts/vendor/heap-addeventproperties-identify.js' }}
|
|
43
|
+
}
|
|
44
|
+
{{/unless}}
|
|
40
45
|
{{#unless nogtm}}
|
|
41
46
|
{{ fileInclude 'node_modules/mod-build/src/scripts/vendor/google-tag-manager-head.js' }}
|
|
42
47
|
{{/unless}}
|