forked from elkos/panopticon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
74 lines (63 loc) · 1.72 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
/* global require */
var gulp = require('gulp');
var mainBowerFiles = require('gulp-main-bower-files');
var uglify = require('gulp-uglify');
var cleanCSS = require('gulp-clean-css');
var gulpFilter = require('gulp-filter');
var eslint = require('gulp-eslint');
var stylelint = require('gulp-stylelint');
var webserver = require('gulp-webserver');
var lintPathsJS = [
'static/js/*.js',
'gulpfile.js'
];
var lintPathsCSS = [
'static/css/*.css'
];
gulp.task('js:lint', () => {
return gulp.src(lintPathsJS)
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('css:lint', () => {
return gulp.src(lintPathsCSS)
.pipe(stylelint({
reporters: [{ formatter: 'string', console: true}]
}));
});
gulp.task('webserver', function() {
gulp.src('.')
.pipe(webserver({
livereload: true,
directoryListing: false,
open: true,
host: 'localhost',
port: '8080',
path: '/'
}));
});
gulp.task('bower', function(){
var filterJS = gulpFilter('**/*.js', { restore: true });
var filterCSS = gulpFilter('**/*.css', { restore: true });
return gulp.src('./bower.json')
.pipe(mainBowerFiles())
.pipe(filterJS)
.pipe(uglify())
.pipe(filterJS.restore)
.pipe(filterCSS)
.pipe(cleanCSS())
.pipe(filterCSS.restore)
.pipe(gulp.dest('./static/lib'));
});
gulp.task('build', function() {
gulp.start('bower');
});
gulp.task('test', function() {
gulp.start('js:lint');
gulp.start('css:lint');
});
gulp.task('run', function() {
gulp.start('webserver');
});
gulp.task('default', ['build', 'test', 'run']);