forked from zlcaosh/Paris
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
76 lines (67 loc) · 2.32 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
76
// require gulp
var gulp = require('gulp')
// require packages
var developServer = require('gulp-develop-server')
var imagemin = require('gulp-imagemin')
var jshint = require('gulp-jshint')
var minifyCSS = require('gulp-minify-css')
var rename = require('gulp-rename')
var sourcemaps = require('gulp-sourcemaps')
var stylus = require('gulp-stylus')
var uglify = require('gulp-uglify')
var nib = require('nib')
// jshint javascript files
gulp.task('lint', function() {
gulp.src('./modules/*.js')
.pipe(jshint({asi: true}))
.pipe(jshint.reporter('default'))
gulp.src('./public/src/scripts/*.js')
.pipe(jshint({asi: true}))
.pipe(jshint.reporter('default'))
})
// compile client scripts
gulp.task('scripts', function() {
gulp.src('./public/src/scripts/*.js')
.pipe(gulp.dest('./public/dist/scripts'))
.pipe(sourcemaps.init())
.pipe(uglify())
.pipe(rename({suffix: '.min'}))
.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: '/dist/scripts/'}))
.pipe(gulp.dest('./public/dist/scripts'))
})
// compile client stylus
gulp.task('styles', function() {
gulp.src('./public/src/styles/texas.styl')
.pipe(stylus({compress: false, use: nib()}))
.pipe(gulp.dest('./public/dist/styles'))
.pipe(sourcemaps.init())
.pipe(minifyCSS())
.pipe(rename({suffix: '.min'}))
.pipe(sourcemaps.write('.', {includeContent: false, sourceRoot: '/dist/styles/'}))
.pipe(gulp.dest('./public/dist/styles'))
})
// copy images
gulp.task('image', function() {
gulp.src('./public/src/images/*.*')
.pipe(imagemin({
optimizationLevel: 3,
progressive: true,
interlaced: true,
multipass: true
}))
.pipe(gulp.dest('./public/dist/images'))
})
// setup a development server
gulp.task('development', function() {
developServer.listen({path: './app.js'})
})
// rerun the task when a file changes
gulp.task('watch', function() {
gulp.watch(['./app.js', './modules/*.js', './views/*.jade'], developServer.restart)
gulp.watch('./public/src/scripts/*.js', ['lint', 'scripts'])
gulp.watch('./public/src/styles/*.styl', ['styles'])
gulp.watch('./public/src/images/*.*', ['image'])
})
// tasks
gulp.task('build', ['lint', 'scripts', 'styles', 'image'])
gulp.task('default', ['build', 'development', 'watch'])