forked from FormidableLabs/nuka-carousel
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Gulpfile.js
73 lines (59 loc) · 1.77 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
'use strict';
var gulp = require('gulp');
var gutil = require('gulp-util');
var gulpIf = require('gulp-if');
var open = require('gulp-open');
var babel = require('gulp-babel');
var del = require('del');
var webpack = require('webpack');
var gwebpack = require('gulp-webpack');
var WebpackDevServer = require('webpack-dev-server');
var eslint = require('gulp-eslint');
var Server = require('karma').Server;
var webpackDistConfig = require('./webpack.dist.config.js'),
webpackDevConfig = require('./webpack.config.js');
function isFixed(file) {
// Has ESLint fixed the file contents?
return file.eslint !== null && file.eslint.fixed;
}
gulp.task('open', function() {
open('', {url: 'http://localhost:8080/webpack-dev-server/'});
});
gulp.task('babel', function() {
return gulp.src('src/*.js')
.pipe(babel())
.pipe(gulp.dest('lib'));
});
gulp.task('webpack-dev-server', function(callback) {
new WebpackDevServer(webpack(webpackDevConfig), {
publicPath: '/assets/',
contentBase: 'demo',
stats: {
colors: true
}
}).listen(8080, 'localhost', function(err) {
if (err) throw new gutil.PluginError('webpack-dev-server', err);
});
});
gulp.task('lint', function() {
return gulp.src(['src/**/*.js'])
.pipe(eslint())
.pipe(eslint.format())
});
gulp.task('lint:fix', function() {
return gulp.src(['src/**/*.js'])
.pipe(eslint({ fix: true }))
.pipe(eslint.format())
// if fixed, write the file to dest
.pipe(gulpIf(isFixed, gulp.dest('src')));
});
gulp.task('karma', ['lint'], function() {
var server = new Server({
configFile: __dirname + '/karma.conf.js',
singleRun: true
})
server.start()
});
gulp.task('test', ['lint', 'karma']);
gulp.task('build', ['babel']);
gulp.task('default', ['webpack-dev-server', 'open']);