-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
35 lines (30 loc) · 1.08 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
const gulp = require('gulp');
const babel = require('gulp-babel');
const changed = require('gulp-changed');
const plumber = require('gulp-plumber');
const del = require('del');
const sourcemaps = require('gulp-sourcemaps');
const paths = {
source: {
js: 'src/**/*.js',
},
build: {
node: 'dist',
esm: 'esm',
},
};
const transpile = (destination, config) =>
gulp
.src(paths.source.js)
.pipe(changed(destination))
.pipe(plumber())
.pipe(sourcemaps.init({ identityMap: true }))
.pipe(babel(config))
.pipe(sourcemaps.write('__sourcemaps__', { sourceRoot: '/snack-build/src' }))
.pipe(gulp.dest(destination));
gulp.task('build:node', () => transpile(paths.build.node));
gulp.task('build:esm', () => transpile(paths.build.esm, require('./.babelrc.esm.json')));
gulp.task('clean', () => del([paths.build.node, paths.build.esm]));
gulp.task('build', gulp.series('clean', gulp.parallel('build:node', 'build:esm')));
gulp.task('watch', gulp.series('build', () => gulp.watch(paths.source.js, gulp.series('build'))));
gulp.task('default', gulp.series('watch'));