mod-build 3.6.5 → 3.6.7--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 +4 -4
- package/gulp-tasks/cache-bust.js +2 -2
- package/gulp-tasks/grab-shared-scripts.js +66 -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 +3 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 3.6.7
|
|
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.5
|
|
4
8
|
|
|
5
9
|
- Updating `settings_tolerance` & `library_tolerance` parameters default values in the VWO script to help reduce Heap-VWO undefined properties (for more information on these parameters you can read here -> https://help.vwo.com/hc/en-us/articles/900001789546-Why-Does-VWO-SmartCode-Time-out-and-How-to-Resolve-It-)
|
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,66 @@
|
|
|
1
|
+
var request = require('request');
|
|
2
|
+
var source = require('vinyl-source-stream');
|
|
3
|
+
var replace = require('gulp-replace');
|
|
4
|
+
var hash = require('gulp-hash');
|
|
5
|
+
var tap = require('gulp-tap');
|
|
6
|
+
var path = require('path');
|
|
7
|
+
|
|
8
|
+
var modAlyticsFileName = '';
|
|
9
|
+
|
|
10
|
+
function replaceModalyticsSrcInHead(gulp, gulpPlugins, siteSettings, siteData) {
|
|
11
|
+
if (siteData.siteData && siteData.siteData.isQuotePage === true || siteData.siteData && siteData.siteData.useRelativePathForResources === true) {
|
|
12
|
+
return gulp.src(siteSettings.srcFolder + '/shared-components/head/head.html')
|
|
13
|
+
.pipe(replace(/".*(modalytics).*"/, '"resources/scripts/mod-alytics/' + modAlyticsFileName + '"'))
|
|
14
|
+
.pipe(gulp.dest(siteSettings.srcFolder + '/shared-components/head'));
|
|
15
|
+
} else {
|
|
16
|
+
return gulp.src(siteSettings.srcFolder + '/shared-components/head/head.html')
|
|
17
|
+
.pipe(replace(/".*(modalytics).*"/, '"/resources/scripts/mod-alytics/' + modAlyticsFileName + '"'))
|
|
18
|
+
.pipe(gulp.dest(siteSettings.srcFolder + '/shared-components/head'));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function copyCurrentModalytics(gulp, gulpPlugins, siteSettings, siteData) {
|
|
23
|
+
return new Promise(resolve => {
|
|
24
|
+
request(`https://${siteSettings.nodeEnv}/quote/resources/mod-alytics/modalytics.min.js`)
|
|
25
|
+
.on('response', resp => {
|
|
26
|
+
if (resp.statusCode !== 200) {
|
|
27
|
+
throw new Error(`${resp.statusCode} Error while fetching modalytics.min.js`);
|
|
28
|
+
}
|
|
29
|
+
})
|
|
30
|
+
.pipe(source('modalytics.min.js'))
|
|
31
|
+
.pipe(hash({
|
|
32
|
+
hashLength: 20,
|
|
33
|
+
template: 'modalytics-<%= hash %>.min.js'
|
|
34
|
+
}))
|
|
35
|
+
.pipe(tap(function(file, t){
|
|
36
|
+
modAlyticsFileName = path.basename(file.path);
|
|
37
|
+
}))
|
|
38
|
+
.pipe(gulp.dest(`${siteSettings.srcFolder}/resources/scripts/mod-alytics`))
|
|
39
|
+
.on('finish', resolve);
|
|
40
|
+
})
|
|
41
|
+
.then(() => {
|
|
42
|
+
return new Promise(resolve => {
|
|
43
|
+
request(`https://${siteSettings.nodeEnv}/quote/resources/mod-alytics/modalytics.min.js.map`)
|
|
44
|
+
.on('response', resp => {
|
|
45
|
+
if (resp.statusCode !== 200) {
|
|
46
|
+
throw new Error(`${resp.statusCode} Error while fetching modalytics.min.js.map`);
|
|
47
|
+
} else {
|
|
48
|
+
replaceModalyticsSrcInHead(gulp, gulpPlugins, siteSettings, siteData);
|
|
49
|
+
}
|
|
50
|
+
})
|
|
51
|
+
.pipe(source('modalytics.min.js.map'))
|
|
52
|
+
.pipe(gulp.dest(`${siteSettings.srcFolder}/resources/scripts/mod-alytics`))
|
|
53
|
+
.on('finish', resolve);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
|
|
58
|
+
return function() {
|
|
59
|
+
const { nodeEnv } = siteSettings;
|
|
60
|
+
if (!nodeEnv) {
|
|
61
|
+
throw new Error('Missing environment variables. Did you start with gulp instead of npm run...?');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
return copyCurrentModalytics(gulp, gulpPlugins, siteSettings, siteData);
|
|
65
|
+
};
|
|
66
|
+
};
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mod-build",
|
|
3
|
-
"version": "3.6.
|
|
3
|
+
"version": "3.6.7--beta.1",
|
|
4
4
|
"description": "Share components for S3 sites.",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -25,6 +25,7 @@
|
|
|
25
25
|
"gulp-eslint-threshold": "^0.1.1",
|
|
26
26
|
"gulp-filter": "^5.0.0",
|
|
27
27
|
"gulp-handlebars-file-include": "^1.0.0",
|
|
28
|
+
"gulp-hash": "^4.2.2",
|
|
28
29
|
"gulp-htmlmin": "^3.0.0",
|
|
29
30
|
"gulp-if": "^2.0.2",
|
|
30
31
|
"gulp-imagemin": "^3.2.0",
|
|
@@ -44,6 +45,7 @@
|
|
|
44
45
|
"gulp-sass-variables": "^1.2.0",
|
|
45
46
|
"gulp-size": "^2.1.0",
|
|
46
47
|
"gulp-sourcemaps": "^2.6.0",
|
|
48
|
+
"gulp-tap": "^2.0.0",
|
|
47
49
|
"gulp-uglify": "^2.1.2",
|
|
48
50
|
"gulp-useref": "^5.0.0",
|
|
49
51
|
"husky": "^1.3.1",
|