-
Notifications
You must be signed in to change notification settings - Fork 10
/
gulpfile.js
75 lines (65 loc) · 2.09 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
// include the required packages.
var gulp = require('gulp')
var stylus = require('gulp-stylus')
var plumber = require('gulp-plumber')
var nib = require('nib')
var minimist = require('minimist')
var gls = require('gulp-live-server')
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var sourcemaps = require('gulp-sourcemaps');
var argv = minimist(process.argv.slice(2))
var paths = {
config: 'config.json',
gulpfile: 'gulpfile.js',
js: {
main: 'src/js/main.js',
thirdparty: [
'jquery-1.11.0.min.js',
'underscore-min.js',
'backbone-min.js',
'imagesloaded.pkgd.min.js',
'jquery.detectSwipe.js',
'scrollfix.js',
'fastclick.js',
'sideburns.js'
].map(function(lib){ return 'src/js/thirdparty/' + lib }),
allThirdparty: 'src/js/thirdparty/*.js'
},
css : {
styl: 'src/css/styles.styl'
// css: 'css/styles.css'
}
}
paths.js.all = paths.js.thirdparty.concat([paths.js.main])
// paths.all = [paths.js.main, paths.css.styl, 'index.html', 'imgs/**/*', 'data/pages.json', 'config.json']
var port = argv.port || process.env.PORT || 8080
var server
gulp.task('serve', function() {
server = gls.static('/public', port)
server.start()
})
gulp.task('compile-stylus', function() {
gulp.src(paths.css.styl)
.pipe(plumber())
.pipe(stylus({
use: nib()
}))
.pipe(gulp.dest('public/css/'))
})
gulp.task('make-js-pkg', function() {
return gulp.src(paths.js.all)
.pipe(plumber())
.pipe(sourcemaps.init())
.pipe(uglify({
//preserveComments: 'some'
}))
.pipe(concat('main.pkgd.min.js')) // The file to write out
.pipe(sourcemaps.write('./')) // Write these in the same folder as our `dest` in the line below
.pipe(gulp.dest('./public/js/'));
});
gulp.task('watch', function() {
gulp.watch([paths.gulpfile, paths.config, paths.css.styl, paths.js.main, paths.js.allThirdparty], ['compile-stylus', 'make-js-pkg'])
});
gulp.task('default', ['compile-stylus']); // Simply compile
gulp.task('watch-files', ['watch', 'compile-stylus', 'make-js-pkg', 'serve']); // Watch files for changes