This repository has been archived by the owner on Nov 13, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathgulpfile.js
101 lines (93 loc) · 2.05 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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
'use strict';
require('babel/register');
var gulp = require('gulp'),
babel = require('gulp-babel'),
eslint = require('gulp-eslint'),
rename = require('gulp-rename'),
reactifySVG = require('./gulp-reactifySVG'),
sync = require('browser-sync'),
webpack = require('gulp-webpack');
var paths = {
webpackFiles: [
'./index.html',
'./assets/bundle.js',
'./assets/styles.css'
],
js: {
src: [
'src/**/*.js',
'src/**/*.jsx'
],
dest: 'lib/'
},
icons: {
src: ['src/icons/*.html'],
dest: 'lib/icons'
},
reactifySVG: [
'gulp-reactifySVG/*.js',
// template file should not be linted
'gulp-reactifySVG/*.jsx'
],
docs: [
'docs/**/*.jsx',
'docs/**/*.js'
],
packed: './assets'
};
gulp.task('transpile', function() {
return gulp.src(paths.js.src)
.pipe(babel())
.pipe(gulp.dest(paths.js.dest));
});
gulp.task('svg', function() {
return gulp.src(paths.icons.src)
.pipe(reactifySVG())
.pipe(rename({
extname: '.jsx'
}))
.pipe(babel())
.pipe(gulp.dest(paths.icons.dest));
});
gulp.task('docs', function() {
return gulp.src(paths.docs + '/DocumentationApplication.js')
.pipe(webpack(require('./webpack.config.js')))
.pipe(gulp.dest('assets/'));
});
gulp.task('sync', ['docs'], function(cb) {
sync({
server: {
baseDir: './',
index: './index.html'
},
files: paths.webpackFiles,
port: 9000,
open: true
}, function() {
cb();
});
});
gulp.task('watch', ['svg', 'transpile', 'docs', 'sync'], function() {
gulp.watch(paths.js.src, ['transpile']);
gulp.watch(
paths.icons.src.concat(paths.reactifySVG),
['svg']
);
gulp.watch(paths.docs.src, ['docs']);
gulp.watch(
paths.js.src.concat(
paths.docs,
paths.reactifySVG
),
['docs']
);
});
gulp.task('lint', function() {
return gulp.src(paths.js.src.concat(
paths.docs,
[paths.reactifySVG[0]]
))
.pipe(eslint())
.pipe(eslint.format());
});
gulp.task('default', ['lint', 'svg', 'transpile', 'docs', 'sync', 'watch']);