2015-06-22 22:47:27 +02:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
var gulp = require('gulp');
|
|
|
|
|
|
|
|
var browserSync = require('browser-sync');
|
2018-08-22 22:21:35 +02:00
|
|
|
var httpProxy = require('http-proxy');
|
2015-06-22 22:47:27 +02:00
|
|
|
|
|
|
|
/* This configuration allow you to configure browser sync to proxy your backend */
|
|
|
|
/*
|
|
|
|
var proxyTarget = 'http://localhost/context/'; // The location of your backend
|
|
|
|
var proxyApiPrefix = 'api'; // The element in the URL which differentiate between API request and static file request
|
|
|
|
var proxy = httpProxy.createProxyServer({
|
|
|
|
target: proxyTarget
|
|
|
|
});
|
|
|
|
function proxyMiddleware(req, res, next) {
|
|
|
|
if (req.url.indexOf(proxyApiPrefix) !== -1) {
|
|
|
|
proxy.web(req, res);
|
|
|
|
} else {
|
|
|
|
next();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
function browserSyncInit(baseDir, files, browser) {
|
|
|
|
browser = browser === undefined ? 'default' : browser;
|
|
|
|
|
|
|
|
browserSync.instance = browserSync.init(files, {
|
|
|
|
startPath: '/index.html',
|
|
|
|
server: {
|
2015-08-19 01:17:20 +02:00
|
|
|
baseDir: baseDir,
|
|
|
|
routes: {
|
|
|
|
'/bower_components': './bower_components'
|
|
|
|
}
|
2015-06-22 22:47:27 +02:00
|
|
|
},
|
|
|
|
browser: browser,
|
|
|
|
ghostMode: false
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
gulp.task('serve', ['watch'], function () {
|
|
|
|
browserSyncInit([
|
|
|
|
'.tmp',
|
2015-07-09 01:34:21 +02:00
|
|
|
'lemur/static/app'
|
2015-06-22 22:47:27 +02:00
|
|
|
], [
|
|
|
|
'.tmp/*.html',
|
|
|
|
'.tmp/styles/**/*.css',
|
|
|
|
'lemur/static/app/angular/**/*.js',
|
|
|
|
'lemur/static/app/partials/**/*.html',
|
|
|
|
'lemur/static/app/images/**/*',
|
|
|
|
'lemur/static/app/angular/**/*',
|
|
|
|
'lemur/static/app/index.html'
|
|
|
|
]);
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
gulp.task('serve:dist', ['build'], function () {
|
|
|
|
browserSyncInit('lemur/static/dist');
|
|
|
|
});
|