-
Notifications
You must be signed in to change notification settings - Fork 38
/
Copy pathgulpfile.babel.js
76 lines (63 loc) · 2 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
import gulp from 'gulp';
import del from 'del';
import babel from 'gulp-babel';
import webpackStream from 'webpack-stream';
import webpack from 'webpack';
import sass from 'gulp-sass';
import postcss from 'gulp-postcss';
import concat from 'gulp-concat';
import pkg from './package.json';
import webpackConfig from './webpack.config';
import exampleWebpackConfig from './example/webpack.config.babel';
require('regenerator-runtime/runtime');
gulp.task('build:lib:clean', async () => del.sync(['lib', 'dist']));
gulp.task('build:lib:babel', async () => {
gulp.src(['src/**/*.js'])
.pipe(babel())
.pipe(gulp.dest('lib'));
});
gulp.task('build:lib:umd', async () => {
gulp.src(['src/index.js'])
.pipe(webpackStream(webpackConfig, webpack))
.pipe(gulp.dest('dist'));
});
gulp.task('build:lib:style', async () => {
gulp.src(['src/**/*.scss', '!src/**/_*.scss'])
.pipe(sass({ outputStyle: 'expanded' }).on('error', sass.logError))
.pipe(gulp.dest('lib'))
.pipe(concat(`${pkg.name}.css`))
.pipe(postcss())
.pipe(gulp.dest('dist'));
});
gulp.task('build:lib:copy', async () => {
gulp.src(['src/**/*', '!src/**/*.{scss,js}'])
.pipe(gulp.dest('lib'))
.pipe(gulp.dest('dist'));
});
gulp.task('build:lib', gulp.series(
'build:lib:clean',
'build:lib:babel',
'build:lib:umd',
'build:lib:style',
'build:lib:copy'
));
gulp.task('build:example:clean', async () => del.sync(['example/dist']));
gulp.task('build:example:webpack', async () => {
gulp.src(['example/app/app.js'], { allowEmpty: true })
.pipe(webpackStream(exampleWebpackConfig, webpack))
.pipe(gulp.dest('example/dist'));
});
gulp.task('build:example:copy', async () => {
gulp.src(['example/app/*', '!example/app/*.{html,js}'], { nodir: true })
.pipe(gulp.dest('example/dist'));
});
gulp.task('build:example', gulp.series(
'build:example:clean',
'build:example:webpack',
'build:example:copy'
));
gulp.task('build', gulp.series(
'build:lib',
'build:example'
));
gulp.task('default', gulp.series('build'));