Skip to content

Instantly share code, notes, and snippets.

@varya
Created February 18, 2015 10:18
Show Gist options
  • Save varya/90d8ce39f6f402e941ce to your computer and use it in GitHub Desktop.
Save varya/90d8ce39f6f402e941ce to your computer and use it in GitHub Desktop.
gulp-express error
'use strict';
(function(module) {
var options = {
// Application options
appPath: './lib/app/app.js',
port: 8080,
livereloadPort: 35729,
// Build options
sourcePath: './src',
outputPath: './new-site-release'
}
module.exports = options;
})(module);
var gulp = require('gulp');
var server = require('gulp-express');
var options = require('./config');
// Shortcats
var sourcePath = options.sourcePath;
var outputPath = options.outputPath;
var appPath = options.appPath;
gulp.task('new:build:app', [
'new:build:html'
// TODO: Add tasks about CSS and JS
]);
gulp.task('new:build:html', function() {
// Copy HTML
return gulp.src(sourcePath + '/**/*.html')
.pipe(gulp.dest(outputPath));
});
gulp.task('new:server', ['new:build:app'], function() {
server.run([
appPath
]);
gulp.watch(sourcePath + '**/*.html', ['new:build:html']);
// liveReload when changes appear
// TODO: can be more specific in the future
gulp.watch(outputPath + '/**', server.notify);
});
gulp.task('default', ['new:server']);
var express = require('express');
var livereload = require('connect-livereload');
var options = require('../../config');
var app = module.exports.app = exports.app = express();
app.use(livereload({
port: options.livereloadPort
}));
app.use(express.static(options.outputPath));
app.listen(options.port);
console.log('Sever is listening to http://localhost:' + options.port);
<html>
<head>
<title>Hello world!</title>
<script src="vendor/libs/angular/angular.js"></script>
<script src="http://localhost:35729/livereload.js"></script>
</head>
<body>
Hello world!
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment