Skip to content
This repository has been archived by the owner on May 4, 2022. It is now read-only.

Commit

Permalink
chore(build): windows error improvements, better cssmin
Browse files Browse the repository at this point in the history
  • Loading branch information
ajoslin committed Mar 8, 2014
1 parent 98672a4 commit c4fb5aa
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 20 deletions.
6 changes: 6 additions & 0 deletions config/version.template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version": "<%= pkg.version %>",
"codename": "<%= pkg.codename %>",
"date": "<%= date %>",
"time": "<%= time %>"
}
57 changes: 39 additions & 18 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ var connect = require('connect');
var dgeni = require('dgeni');
var http = require('http');
var cp = require('child_process');
var fs = require('fs');
var gulp = require('gulp');
var pkg = require('./package.json');
var through = require('through');
Expand All @@ -13,10 +12,10 @@ var argv = require('minimist')(process.argv.slice(2));

var bump = require('gulp-bump');
var concat = require('gulp-concat');
var cssmin = require('gulp-cssmin');
var gulpif = require('gulp-if');
var header = require('gulp-header');
var jshint = require('gulp-jshint');
var minifyCss = require('gulp-minify-css');
var rename = require('gulp-rename');
var sass = require('gulp-sass');
var stripDebug = require('gulp-strip-debug');
Expand All @@ -28,7 +27,7 @@ var banner = _.template(buildConfig.banner, { pkg: pkg });

var IS_RELEASE_BUILD = !!argv.release;
if (IS_RELEASE_BUILD) {
gutil.log(gutil.colors.red('--release=true:'),
gutil.log(gutil.colors.red('--release:'),
'Building release version (minified, debugs stripped)...'
);
}
Expand All @@ -40,7 +39,9 @@ gulp.task('docs', function() {
dgeni('docs/docs.config.js').generateDocs();
});

var IS_WATCH = false;
gulp.task('watch', function() {
IS_WATCH = true;
gulp.watch('js/**/*.js', ['bundle', 'docs']);
gulp.watch('docs/**/*', ['docs']);
gulp.watch('scss/**/*.scss', ['sass']);
Expand All @@ -54,6 +55,7 @@ gulp.task('bundle', [
'scripts',
'scripts-ng',
'vendor',
'version',
], function() {
IS_RELEASE_BUILD && gulp.src(buildConfig.ionicBundleFiles.map(function(src) {
return src.replace(/.js$/, '.min.js');
Expand All @@ -62,16 +64,6 @@ gulp.task('bundle', [
.pipe(concat('ionic.bundle.min.js'))
.pipe(gulp.dest(buildConfig.distJs));

var d = new Date();
fs.writeFileSync('dist/version.json', JSON.stringify({
version: pkg.version,
codename: pkg.codename,
date: d.toISOString().substring(0,10),
time: pad(d.getUTCHours()) +
':' + pad(d.getUTCMinutes()) +
':' + pad(d.getUTCSeconds())
}, null, 2));

return gulp.src(buildConfig.ionicBundleFiles)
.pipe(header(buildConfig.bundleBanner))
.pipe(concat('ionic.bundle.js'))
Expand Down Expand Up @@ -125,18 +117,47 @@ gulp.task('scripts-ng', function() {
.pipe(gulp.dest(buildConfig.distJs));
});

gulp.task('sass', function() {
return gulp.src('scss/ionic.scss')
gulp.task('sass', function(done) {
gulp.src('scss/ionic.scss')
.pipe(header(banner))
.pipe(sass())
.pipe(sass({
onError: function(err) {
//If we're watching, don't exit on error
if (IS_WATCH) {
console.log(gutil.colors.red(err));
} else {
done(err);
}
}
}))
.pipe(concat('ionic.css'))
.pipe(gulp.dest(buildConfig.distCss))
.pipe(gulpif(IS_RELEASE_BUILD, cssmin()))
.pipe(gulpif(IS_RELEASE_BUILD, minifyCss({
keepSpecialComments: 0
})))
.pipe(header(banner))
.pipe(rename({ extname: '.min.css' }))
.pipe(gulp.dest(buildConfig.distCss));
.pipe(gulp.dest(buildConfig.distCss))
.on('end', done);
});

gulp.task('version', function() {
var d = new Date();
var date = d.toISOString().substring(0,10);
var time = pad(d.getUTCHours()) +
':' + pad(d.getUTCMinutes()) +
':' + pad(d.getUTCSeconds());
return gulp.src('config/version.template.json')
.pipe(template({
pkg: pkg,
date: date,
time: time
}))
.pipe(rename('version.json'))
.pipe(gulp.dest('dist'));
});


gulp.task('sauce-connect', sauceConnect);

gulp.task('cloudtest', ['protractor-sauce'], function(cb) {
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
"jshint-stylish": "^0.1.5",
"gulp-template": "^0.1.1",
"gulp-concat": "^2.1.7",
"gulp-cssmin": "^0.1.3",
"gulp-jshint": "^1.5.0",
"gulp-strip-debug": "^0.2.0",
"gulp-sass": "^0.7.1",
Expand All @@ -36,7 +35,8 @@
"canonical-path": "0.0.2",
"lodash": "^2.4.1",
"winston": "^0.7.2",
"minimist": "0.0.8"
"minimist": "0.0.8",
"gulp-minify-css": "^0.3.0"
},
"licenses": [
{
Expand Down

0 comments on commit c4fb5aa

Please sign in to comment.