-
Notifications
You must be signed in to change notification settings - Fork 8
/
gulpfile.js
67 lines (55 loc) · 1.81 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
var gulp = require('gulp')
var mustache = require('gulp-mustache')
var sass = require('gulp-sass')
var autoprefixer = require('gulp-autoprefixer')
var cssmin = require('gulp-cssmin')
var uglify = require('gulp-uglify')
var concat = require('gulp-concat')
var lr
var networks = require('./networks')
function notifyLivereload (event) {
var filename = require('path').relative(__dirname, event.path)
lr.changed({
body: {
files: [ filename ]
}
})
}
gulp.task('views', function () {
return gulp.src('src/index.mustache')
.pipe(mustache({ networks: networks.networkList }, { extension: '.html' }))
.pipe(gulp.dest('.'))
})
gulp.task('styles', function () {
return gulp.src('src/scss/**/*.scss')
.pipe(sass({ errLogToConsole: true }))
.pipe(autoprefixer('last 3 versions'))
.pipe(cssmin())
.pipe(gulp.dest('assets/css'))
})
gulp.task('scripts', function () {
return gulp.src([ 'bower_components/listjs/dist/list.js', 'bower_components/fittext/fittext.js', 'src/js/**/*.js' ])
.pipe(concat('main.js'))
.pipe(uglify())
.pipe(gulp.dest('assets/js'))
})
gulp.task('webserver', function () {
var express = require('express')
var app = express()
app.use(require('connect-livereload')())
app.use(express.static(__dirname))
app.listen(4000)
lr = require('tiny-lr')()
lr.listen(35729)
require('opn')('http://localhost:4000')
})
gulp.task('watch', function () {
gulp.watch('src/**/*.mustache', [ 'views' ])
gulp.watch('src/scss/**/*.scss', [ 'styles' ])
gulp.watch('src/js/**/*.js', [ 'scripts' ])
gulp.watch('**/*.html', notifyLivereload)
gulp.watch('assets/css/**/*.css', notifyLivereload)
gulp.watch('assets/js/**/*.js', notifyLivereload)
})
gulp.task('default', [ 'views', 'scripts', 'styles', 'webserver', 'watch' ])
gulp.task('dry', [ 'views', 'scripts', 'styles' ])