Created
November 6, 2014 12:33
-
-
Save calendee/17b45dbb10110918797d to your computer and use it in GitHub Desktop.
Ionic Build Process
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var gulp = require('gulp'); | |
var minifyCss = require('gulp-minify-css'); | |
var jshint = require('gulp-jshint'); | |
var uglify = require('gulp-uglify'); | |
var rename = require('gulp-rename'); | |
var concat = require('gulp-concat'); | |
var gulpIgnore = require('gulp-ignore'); | |
var rimraf = require('rimraf'); | |
var gutil = require('gulp-util'); | |
var bower = require('bower'); | |
var sass = require('gulp-sass'); | |
var sh = require('shelljs'); | |
var ngAnnotate = require('gulp-ng-annotate'); | |
var paths = { | |
sass: ['./scss/**/*.scss'] | |
}; | |
gulp.task('sass', function(done) { | |
gulp.src('./scss/ionic.app.scss') | |
.pipe(sass()) | |
.pipe(gulp.dest('./src/css/ionic')) | |
.pipe(minifyCss({ | |
keepSpecialComments: 0 | |
})) | |
.pipe(rename({ extname: '.min.css' })) | |
.pipe(gulp.dest('./src/css/ionic')) | |
.on('end', done); | |
}); | |
// Original Ionic Stuff | |
// I hate live reload | |
//gulp.task('watch', function() { | |
// gulp.watch(paths.sass, ['sass']); | |
//}); | |
// | |
//gulp.task('install', ['git-check'], function() { | |
// return bower.commands.install() | |
// .on('log', function(data) { | |
// gutil.log('bower', gutil.colors.cyan(data.id), data.message); | |
// }); | |
//}); | |
// | |
//gulp.task('git-check', function(done) { | |
// if (!sh.which('git')) { | |
// console.log( | |
// ' ' + gutil.colors.red('Git is not installed.'), | |
// '\n Git, the version control system, is required to download Ionic.', | |
// '\n Download git here:', gutil.colors.cyan('http://git-scm.com/downloads') + '.', | |
// '\n Once git is installed, run \'' + gutil.colors.cyan('gulp install') + '\' again.' | |
// ); | |
// process.exit(1); | |
// } | |
// done(); | |
//}); | |
gulp.task('clean-www', function (cb) { | |
rimraf('./www', cb); | |
}); | |
gulp.task('app-html', function() { | |
return gulp.src('src/html/**') | |
.pipe(gulp.dest('www/')); | |
}); | |
gulp.task('app-languages', function() { | |
return gulp.src('src/languages/**') | |
.pipe(gulp.dest('www/languages')); | |
}); | |
gulp.task('app-fonts', function() { | |
return gulp.src([ | |
'src/lib/ionic/fonts/**', | |
'src/lib/comicneue/**' | |
]) | |
.pipe(gulp.dest('www/fonts/')); | |
}); | |
gulp.task('app-images-debug', function() { | |
return gulp.src([ | |
'src/images/**' | |
]) | |
.pipe(gulp.dest('www/images')); | |
}); | |
gulp.task('app-images-prod', function() { | |
return gulp.src([ | |
'src/images/**' | |
]) | |
.pipe(gulp.dest('www/images')); | |
}); | |
gulp.task('app-styles', function() { | |
return gulp.src( | |
[ | |
'src/css/app/app.css', | |
'src/css/app/*.css', | |
'src/lib/comicneue/*.css' | |
], | |
{base: 'src/css'} | |
) | |
.pipe(concat('app.css')) | |
.pipe(gulp.dest('www/css/')); | |
}); | |
gulp.task('vendor-styles', function() { | |
return gulp.src( | |
[ | |
'src/css/ionic/ionic.app.min.css' | |
], | |
{base: 'src/css'} | |
) | |
.pipe(concat('vendor.css')) | |
.pipe(gulp.dest('www/css/')); | |
}); | |
gulp.task('app-js-debug', function() { | |
return gulp.src([ | |
'src/js/app.js', | |
'src/js/**/_*.js', // Use this for all items that must be added before other items. _common.js, _kitCordova.js | |
'src/js/**/*.js' | |
]) | |
.pipe(gulpIgnore.exclude('src/js/lib/firebase.js')) | |
.pipe(jshint()) | |
.pipe(jshint.reporter('default')) | |
.pipe(concat('app.js')) | |
.pipe(ngAnnotate()) | |
.pipe(gulp.dest('www/js/')); | |
}); | |
gulp.task('app-js-prod', function() { | |
return gulp.src([ | |
'src/js/app.js', | |
'src/js/**/*.js' | |
]) | |
.pipe(gulpIgnore.exclude('src/js/lib/firebase-debug.js')) | |
.pipe(jshint()) | |
.pipe(jshint.reporter('default')) | |
.pipe(concat('app.js')) | |
.pipe(ngAnnotate()) | |
.pipe(uglify()) | |
.pipe(gulp.dest('www/js/')); | |
}); | |
gulp.task('vendor-js', function() { | |
return gulp.src( | |
[ | |
'src/lib/ionic/js/ionic.bundle.min.js', | |
'src/lib/angular-translate/angular-translate.min.js', | |
'src/lib/angular-translate/angular-translate-loader-static-files.min', | |
'src/lib/angular-translate/angular-translate-loader-static-files.min', | |
'src/lib/localForage/localforage.min.js', | |
'src/lib/localForage/angular-localForage.min.js', | |
'src/lib/**/*.js', | |
// Don't include these | |
'!src/lib/ionic/angular', | |
'!src/lib/ionic/angular-ui', | |
'!src/lib/ionic/ionic.js', | |
'!src/lib/ionic/ionic.bundle.js', | |
'!src/lib/ionic/ionic-angular.js', | |
'!src/lib/ionic/ionic-angular.min.js' | |
], | |
{base: 'src/js'} | |
) | |
.pipe(concat('vendor.js')) | |
.pipe(gulp.dest('www/js/')); | |
}); | |
gulp.task('build-debug', ['clean-www'], function() { | |
console.log("Debug build in progress"); | |
gulp.start('app-html', 'app-languages', 'app-images-debug', 'app-fonts', 'app-styles', 'vendor-styles', 'app-js-debug', 'vendor-js'); | |
}); | |
gulp.task('default', ['clean-www'], function() { | |
console.log("PRODUCTION BUILD IN PROGRESS"); | |
gulp.start('app-html','app-languages', 'app-images-prod', 'app-fonts', 'app-styles', 'vendor-styles', 'app-js-prod', 'vendor-js'); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi friend, see my template 👯 https://github.com/jdnichollsc/Ionic-Starter-Template