0034283601
Adds boilerplate files from `angularjs-gulp-browserify-boilerplate` to start work on Angular rewrite of the frontend. Change-Id: I54392c24f397496582f9d06d561d5c14a92ccbe6
36 lines
877 B
JavaScript
36 lines
877 B
JavaScript
'use strict';
|
|
|
|
var config = require('../config');
|
|
var http = require('http');
|
|
var express = require('express');
|
|
var gulp = require('gulp');
|
|
var gutil = require('gulp-util');
|
|
var morgan = require('morgan');
|
|
|
|
gulp.task('server', function() {
|
|
|
|
var server = express();
|
|
|
|
// log all requests to the console
|
|
server.use(morgan('dev'));
|
|
server.use(express.static(config.dist.root));
|
|
|
|
// Serve index.html for all routes to leave routing up to Angular
|
|
server.all('/*', function(req, res) {
|
|
res.sendFile('index.html', { root: 'build' });
|
|
});
|
|
|
|
// Start webserver if not already running
|
|
var s = http.createServer(server);
|
|
s.on('error', function(err){
|
|
if(err.code === 'EADDRINUSE'){
|
|
gutil.log('Development server is already started at port ' + config.serverPort);
|
|
}
|
|
else {
|
|
throw err;
|
|
}
|
|
});
|
|
|
|
s.listen(config.serverPort);
|
|
|
|
}); |