-
Notifications
You must be signed in to change notification settings - Fork 36
/
gulpfile.babel.js
122 lines (112 loc) · 3.26 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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
import gulp from 'gulp';
import sass from 'gulp-sass';
import babel from 'gulp-babel';
import del from 'del';
import sourcemaps from 'gulp-sourcemaps';
function clean(str) {
return del([`./lib${str}`]);
}
gulp.task('scss', () => {
clean('/components/styles.css');
return gulp.src('./src/styles.scss')
.pipe(sass({ outputStyle: 'compressed' }).on('error', sass.logError))
.pipe(gulp.dest('./lib'));
});
gulp.task('build:component:SideMenu', () => {
clean('/components/SideMenu.js');
return gulp.src('./src/components/SideMenu.jsx')
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(gulp.dest('./lib/components'));
});
gulp.task('build:component:List', () => {
clean('/components/List.js');
return gulp.src('./src/components/List.jsx')
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(gulp.dest('./lib/components'));
});
gulp.task('build:component:View', () => {
clean('/components/View.js');
return gulp.src('./src/components/View.jsx')
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(gulp.dest('./lib/components'));
});
gulp.task('build:component:Editor', () => {
clean('/components/Editor.js');
return gulp.src('./src/components/Editor.jsx')
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(gulp.dest('./lib/components'));
});
gulp.task('build:component:Markdown', () => {
clean('/components/Markdown.js');
return gulp.src('./src/components/Markdown.jsx')
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(gulp.dest('./lib/components'));
});
gulp.task('build:component:Layout', () => {
clean('/index.js');
return gulp.src('./src/index.jsx')
.pipe(sourcemaps.init())
.pipe(babel())
.pipe(gulp.dest('./lib'));
});
gulp.task('build:middleware', () => {
clean('/middleware.js');
return gulp.src('./src/middleware.js')
.pipe(sourcemaps.init())
.pipe(babel({
presets: [
'stage-0',
[
'env',
{
targets: {
node: '6.10',
},
},
],
],
plugins: [
'transform-flow-comments',
],
babelrc: false,
env: {
production: {
presets: [
'flow',
],
plugins: [
'remove-comments',
],
comments: false,
compact: true,
minified: true,
},
},
}))
.pipe(gulp.dest('./lib'));
});
gulp.task('watch', () => {
gulp.watch('./src/components/styles.scss', gulp.parallel('scss'));
gulp.watch('./src/components/SideMenu.jsx', gulp.parallel('build:component:SideMenu'));
gulp.watch('./src/components/List.jsx', gulp.parallel('build:component:List'));
gulp.watch('./src/components/View.jsx', gulp.parallel('build:component:View'));
gulp.watch('./src/components/Editor.jsx', gulp.parallel('build:component:Editor'));
gulp.watch('./src/components/Markdown.jsx', gulp.parallel('build:component:Markdown'));
gulp.watch('./src/index.jsx', gulp.parallel('build:component:Layout'));
gulp.watch('./src/middleware.js', gulp.parallel('build:middleware'));
});
gulp.task('default', gulp.parallel(
'scss',
'build:component:SideMenu',
'build:component:List',
'build:component:View',
'build:component:Editor',
'build:component:Markdown',
'build:component:Layout',
'build:middleware',
));