mod-build 3.5.1--beta.7 → 3.5.1--beta.8
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/gulp-tasks/build.js +4 -4
- package/gulp-tasks/grab-component-styles.js +46 -0
- package/gulp-tasks/serve.js +3 -3
- package/gulp-tasks/tasks.js +14 -0
- package/package.json +1 -1
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', '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-component-styles', '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', '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-component-styles', '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', '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-component-styles', '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', 'templates', 'styles', 'js-lint', 'html-min', 'css-min', 'js-min', 'img-min', 'extras', 'brand', 'cache-bust', 'build-stat'];
|
|
16
|
+
sequenceOpts = ['clean', 'grab-cdn', 'grab-component-styles', '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() {
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
var request = require('request');
|
|
2
|
+
var source = require('vinyl-source-stream');
|
|
3
|
+
|
|
4
|
+
function streamToDestination(gulp, siteSettings, inputPath, destPath, fileName) {
|
|
5
|
+
return new Promise(resolve => { // eslint-disable-line no-undef
|
|
6
|
+
request(`https://${siteSettings.nodeEnv}/quote/resources/mod-site${inputPath}`)
|
|
7
|
+
.on('response', resp => {
|
|
8
|
+
if (resp.statusCode !== 200) {
|
|
9
|
+
throw new Error('Error fetching about/privacy/terms modals');
|
|
10
|
+
}
|
|
11
|
+
})
|
|
12
|
+
.pipe(source(fileName))
|
|
13
|
+
.pipe(gulp.dest(`${siteSettings.srcFolder}/${destPath}`))
|
|
14
|
+
.on('finish', resolve);
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
module.exports = function(gulp, gulpPlugins, siteSettings, siteData) {
|
|
19
|
+
return function() {
|
|
20
|
+
const { nodeEnv, isLocal } = siteSettings;
|
|
21
|
+
const { isQSPage, isWhiteLabel, includeFaqLink, domain } = siteData;
|
|
22
|
+
const isModWhiteLabel = isWhiteLabel && !isQSPage
|
|
23
|
+
const domainHasModernize = domain.indexOf('modernize') > -1;
|
|
24
|
+
|
|
25
|
+
let externalResources;
|
|
26
|
+
// listing of Static Resources sub-path and site destination paths
|
|
27
|
+
// key: inputPath, value: destPath
|
|
28
|
+
|
|
29
|
+
externalResources = {
|
|
30
|
+
'/shared-components/carousel/styles.scss': ['/styles/shared-components/', 'carousel.scss']
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
if (!nodeEnv) {
|
|
34
|
+
throw new Error('Missing environment variables. Did you start with gulp instead of npm run...?');
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const filesPromiseMap = Object.keys(externalResources).map(key => {
|
|
38
|
+
const destinationPath = externalResources[key][0];
|
|
39
|
+
const fileName = externalResources[key][1];
|
|
40
|
+
return streamToDestination(gulp, siteSettings, key, destinationPath, fileName);
|
|
41
|
+
});
|
|
42
|
+
|
|
43
|
+
// when Promise.all resolves, the streams are done and we can go to the next step
|
|
44
|
+
return Promise.all(filesPromiseMap); // eslint-disable-line no-undef
|
|
45
|
+
};
|
|
46
|
+
};
|
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', 'templates', 'styles', 'compile', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
|
|
7
|
+
sequenceOpts = ['clean', 'grab-cdn', 'grab-component-styles', 'templates', 'styles', 'compile', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
|
|
8
8
|
} else if (siteData.isQSPage) {
|
|
9
|
-
sequenceOpts = ['clean', 'grab-cdn', 'templates', 'styles', 'grab-theme-json', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
|
|
9
|
+
sequenceOpts = ['clean', 'grab-cdn', 'grab-component-styles', 'templates', 'styles', 'grab-theme-json', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
|
|
10
10
|
} else {
|
|
11
|
-
sequenceOpts = ['clean', 'grab-cdn', 'templates', 'styles', 'grab-tooltips-json', 'combine-files', 'grab-images', 'js-lint'];
|
|
11
|
+
sequenceOpts = ['clean', 'grab-cdn', 'grab-component-styles', '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,6 +42,20 @@ module.exports = function() {
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
|
|
45
|
+
// Grab component scss files from CDN so they can be swapped into build
|
|
46
|
+
'grab-component-styles': {
|
|
47
|
+
subtasks: [],
|
|
48
|
+
func: function(opts) {
|
|
49
|
+
if ('undefined' === typeof opts.gulpTasksFolderPath) {
|
|
50
|
+
opts.gulpTasksFolderPath = '.';
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (opts.siteData.useCDN) {
|
|
54
|
+
return require(opts.gulpTasksFolderPath + '/grab-component-styles')(opts.gulp, opts.gulpPlugins, opts.gulpSettings, opts.siteData);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
},
|
|
58
|
+
|
|
45
59
|
// Link scss files
|
|
46
60
|
'sass-lint': {
|
|
47
61
|
subtasks: [],
|