forked from minedun6/web-components
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
83 lines (74 loc) · 2.29 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
const concat = require('gulp-concat'),
gulp = require('gulp'),
minify = require('gulp-minify'),
awspublish = require("gulp-awspublish"),
path = require('path'),
rename = require('gulp-rename'),
NEW_S3_DIRECTORY = 'components';
require('dotenv').config();
// Make a collection of paths used by the various
// build steps
const paths = {
wcscript: [
'./alert/js/dist/pearson-alert.js'
],
dist: './build/',
};
function scripts(done) {
gulp
.src([
'./accordion/js/dist/pearson-accordion.js',
'./alert/js/dist/pearson-alert.js',
'./button-bar/js/dist/pearson-button-bar.js',
'./card/js/dist/pearson-card.js',
'./coachmark/js/dist/pearson-coachmark.js',
'./datepicker/js/dist/pearson-datepicker.js',
'./drawer/js/dist/pearson-drawer.js',
'./dropdown/js/dist/pearson-dropdown.js',
'./file-uploader/js/dist/pearson-file-upload.js',
'./footer/js/dist/pearson-footer.js',
'./header/js/dist/pearson-header.js',
'./loader/js/dist/pearson-loader.js',
'./modal/js/dist/pearson-modal.js',
'./pagination/js/dist/pearson-pagination.js',
'./progress-bar/js/dist/pearson-progress-bar.js',
'./range-slider/js/dist/pearson-range-slider.js',
'./tab-navigation/js/dist/pearson-tabs.js',
'./timepicker/js/dist/pearson-timepicker.js',
'./toggle/js/dist/pearson-toggle.js',
])
.pipe(concat('pearson-web-components.js'))
.pipe(minify())
.pipe(gulp.dest(paths.dist));
done();
}
const build = gulp.series(scripts);
exports.build = build;
exports.default = gulp.series(build);
gulp.task("publish", function() {
var publisher = awspublish.create(
{
region: "sfo2",
endpoint: "sfo2.digitaloceanspaces.com",
params: {
Bucket: "pearsonux"
},
accessKeyId: process.env.S3_KEY,
secretAccessKey: process.env.S3_SECRET
}
);
const headers = {
"Cache-Control": "max-age=315360000, no-transform, public"
};
return (
gulp
.src("./build/pearson-web-components-min.js")
.pipe(rename(function(filePath) {
filePath.dirname = path.join(NEW_S3_DIRECTORY, filePath.dirname);
}))
.pipe(awspublish.gzip({ ext: ".gz" }))
.pipe(publisher.publish(headers))
.pipe(publisher.cache())
.pipe(awspublish.reporter())
);
});