Created
April 26, 2016 16:10
-
-
Save igorpronin/95eb611421c416f505f6990ce814de21 to your computer and use it in GitHub Desktop.
Gulpfile example, from LS Angular Course (lesson 1)
This file contains hidden or 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
'use strict'; | |
var gulp = require('gulp'), | |
concat = require('gulp-concat'), | |
scss = require('gulp-sass'), | |
uglify = require('gulp-uglify'), | |
plumber = require('gulp-plumber'), | |
ngAnnotate = require('gulp-ng-annotate'), | |
sourcemaps = require('gulp-sourcemaps'), | |
webserver = require('gulp-webserver'); | |
gulp.task('js',function(){ | |
gulp.src([ | |
'builds/dev/app/**/*.js', | |
'!builds/dev/app/**/*_test.js' | |
]) | |
.pipe(sourcemaps.init()) | |
.pipe(concat('app.js')) | |
.pipe(plumber()) | |
.pipe(ngAnnotate()) | |
// .pipe(uglify()) | |
.pipe(sourcemaps.write()) | |
.pipe(gulp.dest('builds/dev')); | |
}) | |
gulp.task('jslibs', function(){ | |
gulp.src([ | |
'bower_components/angular/angular.js', | |
// 'bower_components/angular-route/angular-route.js', | |
// 'bower_components/angular-bootstrap/ui-bootstrap-tpls.js', | |
// 'bower_components/angular-file-upload/dist/angular-file-upload.js', | |
// 'bower_components/firebase/firebase-debug.js', | |
// 'bower_components/angularfire/dist/angularfire.js' | |
]) | |
.pipe(concat('libs.js')) | |
.pipe(gulp.dest('builds/dev')); | |
}); | |
gulp.task('pjs',function(){ | |
gulp.src([ | |
'builds/dev/app/**/*.js', | |
'!builds/dev/app/**/*_test.js' | |
]) | |
.pipe(concat('app.js')) | |
.pipe(plumber()) | |
.pipe(ngAnnotate()) | |
.pipe(uglify()) | |
.pipe(gulp.dest('builds/prod')); | |
gulp.src([ | |
'bower_components/angular/angular.min.js', | |
// 'bower_components/angular-route/angular-route.min.js', | |
// 'bower_components/angular-bootstrap/ui-bootstrap-tpls.min.js', | |
]) | |
.pipe(concat('libs.js')) | |
.pipe(gulp.dest('builds/prod')); | |
}) | |
gulp.task('css', function(){ | |
gulp.src('builds/dev/app/**/*.scss') | |
.pipe(plumber()) | |
.pipe(scss()) | |
.pipe(concat('app.css')) | |
.pipe(gulp.dest('builds/dev')); | |
}) | |
gulp.task('csslibs', function(){ | |
gulp.src([ | |
'bower_components/angular/angular-csp.css', | |
'bower_components/bootstrap/dist/css/bootstrap.css', | |
// 'bower_components/angular-bootstrap/ui-bootstrap-csp.css', | |
// 'bower_components/bootstrap/dist/css/bootstrap.css', | |
]) | |
.pipe(concat('theme.css')) | |
.pipe(gulp.dest('builds/dev')); | |
}) | |
gulp.task('pcss', function(){ | |
gulp.src('builds/dev/app/**/*.scss') | |
.pipe(plumber()) | |
.pipe(scss()) | |
.pipe(concat('app.css')) | |
.pipe(uglify()) | |
.pipe(gulp.dest('builds/prod')); | |
gulp.src([ | |
'bower_components/angular/angular-csp.css', | |
'bower_components/angular-bootstrap/ui-bootstrap-csp.css', | |
'bower_components/bootstrap/dist/css/bootstrap.min.css', | |
]) | |
.pipe(concat('theme.css')) | |
.pipe(gulp.dest('builds/prod')); | |
}) | |
gulp.task('phtml', function(){ | |
gulp.src('builds/dev/**/*.html') | |
.pipe(gulp.dest('builds/prod')); | |
}) | |
gulp.task('watch', function(){ | |
gulp.watch('builds/dev/app/**/*.js', ['js']); | |
gulp.watch('builds/dev/app/**/*.scss', ['css']); | |
}) | |
gulp.task('pwatch', function(){ | |
gulp.watch('builds/dev/app/**/*.js', ['pjs']); | |
gulp.watch('builds/dev/app/**/*.scss', ['pcss']); | |
gulp.watch('builds/dev/**/*.html', ['phtml']); | |
}) | |
gulp.task('webserver', function(){ | |
gulp.src('builds/dev') | |
.pipe(webserver({ | |
livereload: true, | |
open: true, | |
port: 8034, | |
})); | |
}) | |
gulp.task('pwebserver', function(){ | |
gulp.src('builds/prod') | |
.pipe(webserver({ | |
livereload: true, | |
open: true, | |
port: 8035, | |
})); | |
}) | |
gulp.task('default', [ | |
'jslibs', | |
'js', | |
'csslibs', | |
'css', | |
'watch', | |
'webserver' | |
]); | |
gulp.task('prod', [ | |
'pjs', | |
'pcss', | |
'phtml', | |
'pwatch', | |
'pwebserver' | |
]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment