Skip to content

Instantly share code, notes, and snippets.

@hellobrian
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hellobrian/9f15ebe038ce84197412 to your computer and use it in GitHub Desktop.
Save hellobrian/9f15ebe038ce84197412 to your computer and use it in GitHub Desktop.
bluemix boilerplate
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'])
});
{
"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"
}
}
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