blob: 4f68afd025eaea9ecf78401b8da3a0803f90ce10 [file] [log] [blame]
/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
* distributed with this work for additional information
* regarding copyright ownership. The ASF licenses this file
* to you under the Apache License, Version 2.0 (the
* "License"); you may not use this file except in compliance
* with the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/
'use strict';
var gulp = require('gulp');
var util = require('util');
var browserSync = require('browser-sync');
var middleware = require('./proxy');
function browserSyncInit(baseDir, files, browser) {
browser = browser === undefined ? 'default' : browser;
var routes = null;
if(baseDir === 'src' || (util.isArray(baseDir) && baseDir.indexOf('src') !== -1)) {
routes = {
// Should be '/bower_components': '../bower_components'
// Waiting for https://github.com/shakyShane/browser-sync/issues/308
'/bower_components': 'bower_components'
};
}
browserSync.instance = browserSync.init(files, {
startPath: '/',
server: {
baseDir: baseDir,
middleware: middleware,
routes: routes
},
browser: browser
});
}
gulp.task('serve', ['watch'], function () {
browserSyncInit([
'src',
'.tmp'
], [
'.tmp/{app,components}/**/*.css',
'src/assets/images/**/*',
'src/*.html',
'src/{app,components}/**/*.html',
'src/{app,components}/**/*.js'
]);
});
gulp.task('serve:dist', ['build'], function () {
browserSyncInit('dist');
});
gulp.task('serve:e2e', function () {
browserSyncInit(['src', '.tmp'], null, []);
});
gulp.task('serve:e2e-dist', ['watch'], function () {
browserSyncInit('dist', null, []);
});