Created
February 18, 2015 10:18
-
-
Save varya/90d8ce39f6f402e941ce to your computer and use it in GitHub Desktop.
gulp-express error
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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']); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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