Skip to content

Instantly share code, notes, and snippets.

@willrax
Last active August 29, 2015 14:14
Show Gist options
  • Save willrax/43f6e3ef8484f6801be9 to your computer and use it in GitHub Desktop.
Save willrax/43f6e3ef8484f6801be9 to your computer and use it in GitHub Desktop.
Angular, Gulp and a Server
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