gulpfile.js task to push js & css to Google Cloud Storage (will add fonts and other files in next PR)

add versioning support to publish:cdn action

fine tune gsutil cmd, add more comments
master
Marc Cohen 2015-06-12 16:50:10 +01:00 committed by Addy Osmani
parent 7435631e4b
commit 277756c5f3
2 changed files with 24 additions and 0 deletions

View File

@ -408,6 +408,28 @@ gulp.task('publish', function(cb) {
cb);
});
// Push the latest version to CDN (Google Cloud Storage)
// This task requires gsutil to be installed and configured.
// For more info on gsutil: https://cloud.google.com/storage/docs/gsutil.
gulp.task('publish:cdn', function() {
var bucket = 'gs://materialdesignlite/';
var info_msg = 'Publishing ' + pkg.version + ' to CDN (' + bucket + ')';
// Build gsutil command to copy each object into the dest bucket.
// -a sets the ACL on each object to public-read
// -m does parallel copies (no help here since one gsutil per file)
// We copy both a default instance at the bucket root and a version
// specific instance into a subdir.
var gsutil_cp_cmd = 'gsutil -m cp -a public-read <%= file.path %> '
+ bucket;
process.stdout.write(info_msg + '\n');
return gulp.src('dist/material.*@(js|css)')
.pipe($.tap(function(file, t) {
file.base = path.basename(file.path);
}))
.pipe($.shell([gsutil_cp_cmd, gsutil_cp_cmd +
pkg.version + '/<%= file.base %>']));
});
gulp.task('publish:push', function() {
var push = !!process.env.GH_PUSH;
if (!push) {

View File

@ -42,8 +42,10 @@
"gulp-rename": "^1.2.0",
"gulp-replace": "^0.5.3",
"gulp-sass": "^1.3.3",
"gulp-shell": "^0.4.2",
"gulp-size": "^1.0.0",
"gulp-sourcemaps": "^1.3.0",
"gulp-tap": "^0.1.3",
"gulp-uglify": "^1.0.1",
"gulp-useref": "^1.0.1",
"gulp-util": "^3.0.4",