-
Notifications
You must be signed in to change notification settings - Fork 10
/
gulpfile.js
56 lines (47 loc) · 1.4 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
/* eslint-env node */
var gulp = require('gulp'),
rename = require('gulp-rename'),
babel = require('gulp-babel'),
eslint = require('gulp-eslint'),
mocha = require('gulp-mocha'),
cleanCSS = require('gulp-clean-css'),
uglify = require('gulp-uglify'),
webserver = require('gulp-webserver');
gulp.task('webserver', function() {
gulp.src('dist')
.pipe(webserver({
livereload: true,
fallback: './examples/es5/index.html',
open: true
}));
});
gulp.task('css', function() {
return gulp.src('./src/*.css')
.pipe(gulp.dest('dist'))
.pipe(rename('codeground.min.css'))
.pipe(cleanCSS({compatibility: 'ie8'}))
.pipe(gulp.dest('dist'));
});
gulp.task('js', ['lint', 'test'], function() {
return gulp.src('./src/*.js')
.pipe(babel())
.pipe(gulp.dest('dist'))
.pipe(rename('Codeground.min.js'))
.pipe(uglify())
.pipe(gulp.dest('dist'));
});
gulp.task('lint', () => {
return gulp.src(['**/*.js','!node_modules/**', '!dist/**/*'])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('test', () => {
return gulp.src('./test/test.js', {read: false})
.pipe(mocha({reporter: 'spec'}));
});
gulp.task('build', ['css', 'js']);
gulp.task('watch', ['build', 'webserver'], function() {
gulp.watch('./src/**/*.css', ['css']);
gulp.watch('./src/**/*.js', ['js']);
});