'use strict';

var gulp = require('gulp');

var browserSync = require('browser-sync');
var httpProxy = require('http-proxy');

/* This configuration allow you to configure browser sync to proxy your backend */
var proxyTarget = 'http://server/context/'; // The location of your backend

var proxy = httpProxy.createProxyServer({
  target: proxyTarget
});

/* proxyMiddleware forwards static files to BrowserSync server
   and forwards dynamic requests to your real backend */
function proxyMiddleware(req, res, next) {
  if (/\.(html|png|css|jpg|jpeg|gif|js|ico|xml|rss|txt)(\?(r|v|rel|rev)=[\-\.\w]*)?$/.test(req.url)) {
    next();
  } else {
    proxy.web(req, res);
  }
}

function browserSyncInit(baseDir, files, browser) {
  browser = browser === undefined ? 'default' : browser;

  browserSync.instance = browserSync.init(files, {
    startPath: '/index.html',
    server: {
      baseDir: baseDir,
      middleware: proxyMiddleware
    },
    browser: browser
  });

}

gulp.task('serve', ['watch'], function () {
  browserSyncInit([
    'app',
    '.tmp'
  ], [
    'app/*.html',
    '.tmp/styles/**/*.css',
    'app/scripts/**/*.js',
    'app/partials/**/*.html',
    'app/images/**/*'
  ]);
});

gulp.task('serve:dist', ['build'], function () {
  browserSyncInit('dist');
});

gulp.task('serve:e2e', function () {
  browserSyncInit(['app', '.tmp'], null, []);
});

gulp.task('serve:e2e-dist', ['watch'], function () {
  browserSyncInit('dist', null, []);
});

@@ -388,16 +388,24 @@
 tic file
+ request
 s to Bro
@@ -539,15 +539,18 @@
 tml%7C
-png%7Ccss
+css%7Cjs%7Cpng
 %7Cjpg
@@ -559,19 +559,16 @@
 peg%7Cgif%7C
-js%7C
 ico%7Cxml%7C
@@ -578,13 +578,31 @@
 %7Ctxt
+%7Ceot%7Csvg%7Cttf%7Cwoff
 )(%5C?(
+(
 r%7Cv%7C
@@ -621,16 +621,18 @@
 %5C.%5Cw%5D*)?
+)?
 $/.test(

Add font files into filter.