Created
November 24, 2015 22:05
-
-
Save ukdave/afbfd428a1c3c9ea2cdb to your computer and use it in GitHub Desktop.
Browsersync with proxy for Spring Boot REST API
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 proxyMiddleware = require('http-proxy-middleware'); | |
var browserSync = require('browser-sync').create(); | |
var sass = require('gulp-sass'); | |
// Static Server + watching scss/html files | |
gulp.task('serve', ['sass'], function() { | |
browserSync.init({ | |
port: 9000, | |
server: "./app" | |
}); | |
gulp.watch("app/assets/*.scss", ['sass']); | |
gulp.watch("app/*.html").on('change', browserSync.reload); | |
}); | |
// Compile sass into CSS & auto-inject into browsers | |
gulp.task('sass', function() { | |
return gulp.src("app/assets/*.scss") | |
.pipe(sass()) | |
.pipe(gulp.dest("app/assets/")) | |
.pipe(browserSync.stream()); | |
}); | |
// Static Server + watching css/html files | |
gulp.task('serve2', ['css'], function() { | |
var proxy = proxyMiddleware('/context/api', {target: 'http://localhost:8080/context/api'}); | |
browserSync.init({ | |
server: { | |
baseDir: ".", | |
routes: { "/context": "app" }, | |
middleware: [ proxy ] | |
}, | |
startPath: '/context' | |
}); | |
gulp.watch("app/assets/*.css", ['css']); | |
gulp.watch("app/*.html").on('change', browserSync.reload); | |
}); | |
gulp.task('css', function() { | |
return gulp.src("app/assets/*.css") | |
.pipe(browserSync.stream()); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment