-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
72 lines (65 loc) · 2.19 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
const gulp = require('gulp'),
sass = require('gulp-dart-sass'),
path = require('path'),
streamify = require('gulp-streamify'),
autoprefixer = require('gulp-autoprefixer'),
minifycss = require('gulp-minify-css'),
browserify = require('browserify'),
babelify = require('babelify'),
sourcemaps = require('gulp-sourcemaps'),
babel = require('gulp-babel'),
source = require('vinyl-source-stream'),
gutil = require('gulp-util'),
jshint = require('gulp-jshint'),
stylish = require('jshint-stylish'),
uglify = require('gulp-uglify'),
minify = require('gulp-babel-minify'),
rename = require('gulp-rename'),
clean = require('gulp-clean'),
concat = require('gulp-concat'),
notify = require('gulp-notify');
function swallow_error(error) {
console.log(error.toString());
this.emit('end');
}
gulp.task('styles', function() {
return gulp.src('src/frontend/styles/*.scss')
.pipe(sass({
paths: [ path.join(__dirname, 'scss', 'includes') ]
}))
.on('error', swallow_error)
.pipe(autoprefixer('last 3 version', 'android >= 3', { cascade: true }))
.on('error', swallow_error)
.pipe(gulp.dest('dist/css'))
.pipe(rename({ suffix: '.min' }))
.pipe(minifycss())
.on('error', swallow_error)
.pipe(gulp.dest('dist/css'));
});
gulp.task('scripts', function() {
gulp.src('src/frontend/scripts/*.js')
.pipe(sourcemaps.init())
.pipe(babel())
.on('error', swallow_error)
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./dist/js'))
});
gulp.task('jslint', function(){
return gulp.src([
'./src/scripts/**/*.js'
]).pipe(jshint('tests/.jshintrc'))
.on('error',gutil.noop)
.pipe(jshint.reporter(stylish))
.on('error', swallow_error);
});
gulp.task('clean', function() {
return gulp.src(['dist/css', 'dist/js'], { read: false })
.pipe(clean());
});
gulp.task('watch', function() {
gulp.watch('src/frontend/styles/**/*.*', ['styles']);
gulp.watch('src/frontend/scripts/**/*.*', ['jslint', 'scripts']);
});
gulp.task('default', ['clean'], function() {
gulp.start('styles', 'jslint', 'scripts', 'watch');
});