forked from FormidableLabs/component-playground
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Gulpfile.js
72 lines (59 loc) · 1.62 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
"use strict";
var gulp = require("gulp");
var gutil = require("gulp-util");
var babel = require("gulp-babel");
var del = require("del");
var WebpackDevServer = require("webpack-dev-server");
var eslint = require("gulp-eslint");
var karma = require("karma").server;
var webpackDemoConfig = require("./demo/webpack.demo.config.js");
gulp.task("clean", function (cb) {
del(["lib"], cb);
});
gulp.task("babel", ["clean"], function () {
return gulp.src("src/*.js*")
.pipe(babel({optional: ["runtime"]}))
.pipe(gulp.dest("lib"));
});
gulp.task("demo", ["build"], function () {
var compiler = webpackDemoConfig;
new WebpackDevServer(compiler, {
contentBase: "./demo",
hot: true,
publicPath: "/demo/assets/",
stats: {
colors: true
}
}).listen(8081, "localhost", function (err) {
if (err) {
throw new gutil.PluginError("webpack-dev-server", err);
}
gutil.log("[demo]", "http://localhost:8081/");
});
});
gulp.task("lint:react", function () {
return gulp.src([
"src/**/*.jsx",
"demo/**/*.jsx"
])
.pipe(eslint({configFile: '.eslintrc-react'}))
.pipe(eslint.format());
});
gulp.task("lint:es5", function () {
return gulp.src([
"./Gulpfile.js",
"./index.js"
])
.pipe(eslint({configFile: '.eslintrc-es5'}))
.pipe(eslint.format());
});
gulp.task("lint", ["lint:es5", "lint:react"]);
gulp.task("karma", ["lint"], function () {
karma.start({
configFile: __dirname + "/karma.conf.js",
singleRun: true
});
});
gulp.task("test", ["karma"]);
gulp.task("build", ["lint", "clean", "babel"]);
gulp.task("default", ["demo"]);