-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
94 lines (84 loc) · 2.56 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
88
89
90
91
92
93
94
var gulp = require('gulp');
var sass = require('gulp-sass');
var sourcemaps = require('gulp-sourcemaps');
var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync');
var reload = browserSync.reload;
var url = require('url');
var proxy = require('proxy-middleware');
var exec = require('child_process').exec;
var notify = require('gulp-notify');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var todo = require('gulp-todo');
var scripts = [
'static_dev/js/jquery-2.1.4.min.js',
'static_dev/js/bin/materialize.min.js',
'static_dev/js/scripts.js'
];
var AUTOPREFIXER_BROWSERS = [
'Android 2.3',
'Android >= 4',
'Chrome >= 20',
'Firefox >= 24',
'Explorer >= 8',
'iOS >= 6',
'Opera >= 12',
'Safari >= 6'
];
gulp.task('runserver', function () {
var proc = exec('python manage.py runserver');
});
gulp.task('collectstatic', function () {
var proc = exec('python manage.py collectstatic --noinput ');
});
gulp.task('sass', function() {
return gulp.src('static_dev/sass/style.scss')
.pipe(sourcemaps.init())
.pipe(sass())
.on('error', notify.onError(function (error) {
return 'Sass error: ' + error.formatted;
}))
.pipe(sourcemaps.write())
.pipe(autoprefixer({browsers: AUTOPREFIXER_BROWSERS}))
.pipe(gulp.dest('static/css'))
.pipe(reload({
stream: true
}));
});
gulp.task('scripts', function() {
return gulp.src(scripts)
.pipe(concat('scripts.js'))
.pipe(uglify())
.on('error', notify.onError(function (error) {
return 'JS error: ' + error.message;
}))
.pipe(gulp.dest('static/js'));
});
gulp.task('images', function() {
return gulp.src('static_dev/images/**/*')
.pipe(gulp.dest('static/img'));
});
gulp.task('todo', function() {
return gulp.src(['**/*.+(js|css|py|scss|html)', '!./node_modules/**'])
.pipe(todo({
fileName: 'TODO.md'
}))
.pipe(gulp.dest('./'));
});
gulp.task('default', ['collectstatic', 'images', 'scripts', 'sass', 'todo', 'runserver'], function () {
browserSync({
notify: false,
proxy: 'http://localhost:8000/',
serveStatic: ['.', './static']
});
gulp.watch(['static_dev/sass/**/*.scss'], ['todo', 'sass']);
gulp.watch(['static_dev/images/**/*'], ['images']);
gulp.watch(['static_dev/js/**/*.js'], ['todo', 'scripts']);
// gulp.watch(['static/css/**/*.css'], reload);
gulp.watch(['*/templates/**/*.html'], ['todo']);
gulp.watch(['*/templates/**/*.html'], reload);
gulp.watch(['**/*.py'], ['todo', reload]);
gulp.watch(['static/js/**/*.js'], reload);
gulp.watch(['static/img/**/*'], reload);
});