From feecd270d5455c8d888a2a23aef7cd075e8f37a2 Mon Sep 17 00:00:00 2001 From: Daniel Freedman Date: Mon, 25 May 2015 14:30:59 -0700 Subject: [PATCH] Refactor build process Use gulp vulcanize to reduce run time and weird interactive delay Use polyclean.leftAlignJs to refactor the strip step Move the strip step into micro/mini/max Add gulp release task to automate for dumping into builds branch Fixes #1519 [0.9] New gulp build hangs until enter key is pressed --- .gitignore | 1 + gulpfile.js | 127 ++++++++++++++++++++++++++++----------------------- package.json | 8 ++-- 3 files changed, 75 insertions(+), 61 deletions(-) diff --git a/.gitignore b/.gitignore index 7bf6eb18f7..372e20a51b 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ bower_components node_modules +dist diff --git a/gulpfile.js b/gulpfile.js index e3ce67358e..3b2f4da45c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,51 +1,63 @@ +/** + * @license + * Copyright (c) 2014 The Polymer Project Authors. All rights reserved. + * This code may only be used under the BSD style license found at http:polymer.github.io/LICENSE.txt + * The complete set of authors may be found at http:polymer.github.io/AUTHORS.txt + * The complete set of contributors may be found at http:polymer.github.io/CONTRIBUTORS.txt + * Code distributed by Google as part of the polymer project is also + * subject to an additional IP rights grant found at http:polymer.github.io/PATENTS.txt + */ + +// jshint node: true +'use strict'; + var gulp = require('gulp'); var audit = require('gulp-audit'); var replace = require('gulp-replace'); -var shell = require('gulp-shell'); var rename = require('gulp-rename'); +var vulcanize = require('gulp-vulcanize'); var runseq = require('run-sequence'); +var lazypipe = require('lazypipe'); +var polyclean = require('polyclean'); var del = require('del'); + var fs = require('fs'); var path = require('path'); -var polyclean = require('polyclean'); - -function vulcanize(filename, dstdir, excludes) { - var cmd = path.join('node_modules', '.bin', 'vulcanize'); - if (excludes && excludes.length > 0) { - excludes.forEach(function(exclude) { - cmd = cmd + ' --exclude ' + exclude; - }); - } - cmd = cmd + ' --strip-comments'; - cmd = cmd + ' ' + filename + ' > ' + path.join(dstdir, filename); - return cmd; -} - var micro = "polymer-micro.html"; var mini = "polymer-mini.html"; var max = "polymer.html"; var workdir = 'dist'; -gulp.task('micro', ['mkdir'], shell.task(vulcanize(micro, workdir))); -gulp.task('mini', ['mkdir'], shell.task(vulcanize(mini, workdir, [micro]))); -gulp.task('max', ['mkdir'], shell.task(vulcanize(max, workdir, [mini, micro]))); - -gulp.task('strip', ['micro', 'mini', 'max'], function() { - return gulp.src(['dist/' + micro, 'dist/' + mini, 'dist/' + max]) - .pipe(polyclean.cleanJsComments()) - // Collapse newlines - .pipe(replace(/\n\s*\n/g, '\n')) - // Reduce script tags - .pipe(replace(/<\/script>\s*