forked from imtoobose/voting-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
65 lines (60 loc) · 1.76 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
var
gulp = require('gulp'),
autoprefixer = require('gulp-autoprefixer'),
sass = require('gulp-sass'),
changed = require('gulp-changed'),
babel = require('gulp-babel'),
uglify = require('gulp-uglify'),
path = require('path'),
uglifycss = require('gulp-clean-css'),
browserSync = require('browser-sync').create();
nodemon = require('gulp-nodemon');
gulp.task('sass', function(){
gulp.src('app/static/dev/css/*.scss')
.pipe(changed('app/static/dist'))
.pipe(sass()).on('error', sass.logError)
.pipe(autoprefixer())
.pipe(uglifycss())
.on('end', ()=>console.log('\033[92mSass\033[0m files compiled'))
.pipe(gulp.dest('app/static/dist/css'))
.pipe(browserSync.stream());
});
gulp.task('staticjs', function(){
gulp.src('app/static/dev/**/*.js')
.pipe(changed('app/static/dist'))
.pipe(babel({
presets: ['es2015']
}))
.on('end', ()=> console.log('\033[92mBabel\033[0m transpiled'))
.on('error', (e)=> console.log(e))
.pipe(uglify())
.pipe(gulp.dest('app/static/dist'))
.on('end', ()=> console.log('\033[92mCompiled and saved static js\033[0m'))
.pipe(browserSync.stream());
});
gulp.task('start', ['staticjs', 'sass'], function (cb) {
var started = false;
nodemon({
script: 'server.js',
ext: 'js pug',
ignore: 'app/static/*'
})
.on("start", ()=>{
if(!started){
started = true;
browserSync.init(null, {
proxy: "http://127.0.0.1:8080",
port: 3000
});
cb();
}
setTimeout(
browserSync.reload,
3000
)
})
.on("error", (err)=> console.log(err.toString()));
gulp.watch('app/static/**/*.js', ['staticjs']);
gulp.watch('app/static/**/*.scss', ['sass']);
});
gulp.task('default', ['start']);