Last active
August 29, 2015 14:14
-
-
Save willrax/43f6e3ef8484f6801be9 to your computer and use it in GitHub Desktop.
Angular, Gulp and a Server
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"), | |
gutil = require("gulp-util"), | |
jshint = require("gulp-jshint"), | |
concat = require("gulp-concat"), | |
clean = require("gulp-clean"), | |
connect = require("gulp-connect"), | |
sourcemaps = require("gulp-sourcemaps"), | |
bowerPath = "bower_components/"; | |
var bowerComponents = [ | |
bowerPath + "angular/angular.js", | |
bowerPath + "angular-ui-router/release/angular-ui-router.min.js" | |
]; | |
gulp.task("lint", function() { | |
gulp.src(["app/*.js", "app/**/*.js"]) | |
.pipe(jshint()) | |
.pipe(jshint.reporter("default")); | |
}); | |
gulp.task("javascript", function() { | |
gulp.src(["app/app.js", "app/**/*.js"]) | |
.pipe(concat("app.js")) | |
.pipe(gulp.dest(".dist")) | |
.pipe(connect.reload()); | |
}); | |
gulp.task("bower", function() { | |
gulp.src(bowerComponents) | |
.pipe(sourcemaps.init()) | |
.pipe(concat("vendor.js")) | |
.pipe(sourcemaps.write()) | |
.pipe(gulp.dest(".dist")); | |
}); | |
gulp.task("html", ["templates"], function() { | |
gulp.src(["app/index.html"]) | |
.pipe(gulp.dest(".dist")) | |
.pipe(connect.reload()); | |
}); | |
gulp.task("templates", function() { | |
gulp.src(["app/templates/*.html"]) | |
.pipe(gulp.dest(".dist/templates")) | |
.pipe(connect.reload()); | |
}); | |
gulp.task("dev", function() { | |
gulp.watch(["app/*.js", "app/**/*.js"],[ | |
"lint", | |
"javascript" | |
]); | |
gulp.watch(["app/index.html"], ["html"]); | |
gulp.watch(["app/templates/*.html"], ["templates"]); | |
}); | |
gulp.task("webserver", function() { | |
connect.server({ | |
root: ".dist", | |
port: 4200, | |
livereload: true | |
}); | |
}); | |
gulp.task("default", ["html", "bower", "javascript", "webserver", "dev"]); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment