-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
87 lines (76 loc) · 2.07 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
77
78
79
80
81
82
83
84
85
86
87
var gulp = require('gulp');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var nodemon = require('gulp-nodemon');
var sass = require('gulp-sass');
var bower = require('gulp-bower');
var rename = require('gulp-rename');
var minifyCss = require('gulp-minify-css');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var config = {
js: 'dev/js/*.js',
sassPath: './sass',
bowerDir: './bower_components',
// fontawesome: config.bowerDir + 'fontawesome'
};
// gulp.task('bower', function() {
// return bower()
// .pipe(gulp.dest(config.bowerDir));
// });
// gulp.task('icons', function() {
// return gulp.src(config.bowerDir + '/fontawesome/fonts/**.*)'
// .pipe(gulp.dest('./public/fonts'))
// );
// });
gulp.task('browser-sync', ['nodemon'], function() {
browserSync({
proxy: "localhost:3000", // local node app address
port: 5000, // use *different* port than above
notify: true
});
});
gulp.task('uglifyjs', function() {
gulp.src(config.js)
.pipe(uglify())
.pipe(rename('init.min.js'))
.pipe(gulp.dest('public/js/'));
});
gulp.task('nodemon', function (cb) {
var called = false;
return nodemon({
script: 'server.js',
ignore: [
'gulpfile.js',
'node_modules/'
]
})
.on('start', function () {
if (!called) {
called = true;
cb();
}
})
.on('restart', function () {
setTimeout(function () {
reload({ stream: false });
}, 1000);
});
});
gulp.task('compile-sass', function () {
gulp.src('./dev/scss/**/*.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest('./dev/css'));
});
gulp.task('concat-css', ['compile-sass'], function () {
gulp.src('./dev/css/**/*.css')
.pipe(concat('styles.min.css'))
.pipe(minifyCss())
.pipe(gulp.dest('public/css'));
});
gulp.task('sass:watch', function () {
gulp.watch('./dev/scss/**/*.scss', ['concat-css'], reload);
});
gulp.task('default', ['browser-sync','uglifyjs','concat-css', 'sass:watch'], function () {
gulp.watch(['index.html', 'public/css/style.min.css'], reload);
});