-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.babel.js
55 lines (46 loc) · 1.22 KB
/
gulpfile.babel.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
/* eslint-disable import/no-extraneous-dependencies */
import gulp from 'gulp';
import babel from 'gulp-babel';
import uglify from 'gulp-uglify';
import rename from 'gulp-rename';
import del from 'del';
import eslint from 'gulp-eslint';
import { Server } from 'karma';
const paths = {
srcDir: 'src/**/*.js',
gulpFile: 'gulpfile.babel.js',
distDir: 'dist',
testsDir: 'test/**/*.spec.js',
karmaConfigFile: `${__dirname}/karma.conf.js`,
};
gulp.task('clean', () => del(paths.distDir));
gulp.task('lint', () =>
gulp.src([paths.srcDir, paths.gulpFile, paths.testsDir])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError())
);
gulp.task('build', ['lint', 'clean'], () =>
gulp.src(paths.srcDir)
.pipe(babel())
.pipe(gulp.dest(paths.distDir))
.pipe(uglify())
.pipe(rename({ suffix: '.min' }))
.pipe(gulp.dest(paths.distDir))
);
gulp.task('watch', () => {
gulp.watch(paths.srcDir, ['default']);
});
gulp.task('test', done =>
new Server({
configFile: paths.karmaConfigFile,
singleRun: true,
}, done).start()
);
gulp.task('tdd', done =>
new Server({
configFile: paths.karmaConfigFile,
singleRun: false,
}, done).start()
);
gulp.task('default', ['watch', 'build']);