Last active
August 29, 2015 14:04
-
-
Save noxan/adf6172f859c6ef6ada5 to your computer and use it in GitHub Desktop.
gulp + connectjs + angularjs + jade + stylus + browserify + jshint + bower + livereload (single folder structure)
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 $ = require('gulp-load-plugins')(); | |
var wiredep = require('wiredep'); | |
// config | |
var path = require('path'); | |
var config = { | |
server: { | |
port: 3000 | |
}, | |
livereload: { | |
port: 35729 | |
}, | |
rootDirectory: path.resolve(__dirname), | |
} | |
config.buildDirectory = path.resolve(config.rootDirectory + '/build') | |
config.sourceDirectory = path.resolve(config.rootDirectory + '/client') | |
config.scripts = { | |
buildDirectory: path.resolve(config.buildDirectory + '/scripts'), | |
buildFilename: 'bundle.js', | |
source: path.resolve(config.sourceDirectory + '/scripts/index.js'), | |
watch: path.resolve(config.sourceDirectory + '/scripts/**/*.js') | |
} | |
config.styles = { | |
buildDirectory: path.resolve(config.buildDirectory + '/styles'), | |
buildFilename: 'bundle.css', | |
source: path.resolve(config.sourceDirectory + '/styles/index.styl'), | |
watch: path.resolve(config.sourceDirectory + '/styles/**/*.styl') | |
} | |
config.views = { | |
source: path.resolve(config.sourceDirectory + '/**/*.jade'), | |
buildDirectory: config.buildDirectory, | |
watch: path.resolve(config.sourceDirectory + '/**/*.jade') | |
} | |
// end config | |
gulp.task('scripts', ['jshint'], function() { | |
gulp.src(config.scripts.source) | |
.pipe($.plumber()) | |
.pipe($.browserify()) | |
.pipe($.rename(config.scripts.buildFilename)) | |
.pipe(gulp.dest(config.scripts.buildDirectory)); | |
}); | |
gulp.task('jshint', function() { | |
gulp.src(config.scripts.source) | |
.pipe($.jshint()) | |
.pipe($.jshint.reporter('default')); | |
}); | |
gulp.task('styles', function() { | |
gulp.src(config.styles.source) | |
.pipe($.plumber()) | |
.pipe($.cssjoin()) | |
.pipe($.stylus()) | |
.pipe($.rename(config.styles.buildFilename)) | |
.pipe(gulp.dest(config.styles.buildDirectory)); | |
}); | |
gulp.task('views', function() { | |
gulp.src(config.views.source) | |
.pipe($.plumber()) | |
.pipe($.jade()) | |
.pipe(gulp.dest(config.views.buildDirectory)); | |
}); | |
gulp.task('libs', function() { | |
var bower = wiredep(); | |
gulp.src(bower.js) | |
.pipe($.concatSourcemap('libs.js')) | |
.pipe(gulp.dest('build/scripts')); | |
gulp.src(bower.css) | |
.pipe($.concatSourcemap('libs.css')) | |
.pipe(gulp.dest('build/styles')); | |
}); | |
gulp.task('nodemon', function() { | |
$.nodemon({ | |
script: 'server/index.js', | |
watch: 'server' | |
}); | |
}); | |
gulp.task('watch', function() { | |
gulp.watch(config.scripts.watch, ['scripts']); | |
gulp.watch(config.styles.watch, ['styles']); | |
gulp.watch(config.views.watch, ['views']); | |
gulp.watch('bower.json', ['libs']); | |
}); | |
gulp.task('build', ['libs', 'scripts', 'styles', 'views']); | |
gulp.task('default', ['build', 'watch', 'nodemon']); |
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": "", | |
"version": "", | |
"description": "", | |
"license": "", | |
"author": "", | |
"main": "server/index.js", | |
"dependencies": { | |
"connect": "^3.0.1", | |
}, | |
"devDependencies": { | |
"connect-livereload": "^0.4.0", | |
"gulp": "^3.8.5", | |
"gulp-browserify": "^0.5.0", | |
"gulp-concat-sourcemap": "^1.3.1", | |
"gulp-cssjoin": "^0.1.2", | |
"gulp-jade": "^0.6.1", | |
"gulp-jshint": "^1.7.0", | |
"gulp-load-plugins": "^0.5.3", | |
"gulp-nodemon": "^1.0.4", | |
"gulp-plumber": "^0.6.3", | |
"gulp-rename": "^1.2.0", | |
"gulp-stylus": "^1.0.3", | |
"gulp-watch": "^0.6.8", | |
"node-watch": "^0.3.4", | |
"serve-static": "^1.3.0", | |
"tiny-lr": "0.0.9", | |
"wiredep": "^1.8.2" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment