Last active
August 29, 2015 14:14
-
-
Save hellobrian/9f15ebe038ce84197412 to your computer and use it in GitHub Desktop.
bluemix boilerplate
This file contains hidden or 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 browserSync = require('browser-sync'); | |
var sass = require('gulp-sass'); | |
var plumber = require('gulp-plumber'); | |
var reload = browserSync.reload; | |
// browser-sync task for starting the server. | |
// this task will start a static server from the root directory | |
gulp.task('browser-sync', function() { | |
browserSync({ | |
server: { | |
baseDir: "./" | |
} | |
}); | |
}); | |
// Sass task, will run when any SCSS files change & BrowserSync | |
// will auto-update browsers | |
gulp.task('sass', function () { | |
return gulp.src('scss/**/*.scss') | |
.pipe(plumber()) | |
.pipe(sass()) | |
.pipe(gulp.dest('public/css')) | |
.pipe(reload({stream:true})); | |
}); | |
gulp.task('bs-reload', function () { | |
browserSync.reload(); | |
}) | |
// Default task to be run with `gulp` | |
gulp.task('default', ['sass', 'browser-sync'], function () { | |
gulp.watch("scss/**/*.scss", ['sass']); | |
gulp.watch("*.html", ['bs-reload']) | |
}); |
This file contains hidden or 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
{ | |
"name": "bluemix-boilerplate", | |
"version": "1.0.0", | |
"description": "boilerplate for websites using node, express and gulp", | |
"main": "server.js", | |
"scripts": { | |
"test": "echo \"Error: no test specified\" && exit 1" | |
}, | |
"keywords": [ | |
"gulp", | |
"node", | |
"boilerplate" | |
], | |
"author": "Brian Han @thisisbrianhan", | |
"license": "MIT", | |
"devDependencies": { | |
"browser-sync": "^1.9.0", | |
"gulp": "^3.8.10", | |
"gulp-autoprefixer": "^2.0.0", | |
"gulp-plumber": "^0.6.6", | |
"gulp-sass": "^1.1.0", | |
"gulp-webserver": "^0.8.7" | |
}, | |
"dependencies": { | |
"express": "^4.10.7" | |
} | |
} |
This file contains hidden or 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 app = express(); | |
app.use(express.static(__dirname + '/', { extensions: ['html'] })); | |
var router = express.Router(); | |
router.get('/', function(req, res) { | |
res.sendFile('index.html'); | |
}) | |
router.get('/about', function(req, res) { | |
res.sendFile('about.html'); | |
}); | |
// | |
var host = (process.env.VCAP_APP_HOST || 'localhost'); | |
var port = (process.env.VCAP_APP_PORT || 3000); | |
app.listen(port, host); | |
console.log('App started on port ' + port) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment