-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
83 lines (76 loc) · 1.64 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
const gulp = require('gulp');
const { rollup } = require('rollup');
const { babel } = require('@rollup/plugin-babel');
const { nodeResolve } = require('@rollup/plugin-node-resolve');
const gulpCopy = require('gulp-copy');
const browserSync = require('browser-sync');
const clean = require('gulp-clean');
/**
* A gulp task to process our javascript.
*
* This is a very basic setup. We'll likely want to configure this further.
*/
gulp.task('js', async () => {
const rollupBuild = await rollup({
input: 'demo/demo.js',
plugins: [babel(), nodeResolve()],
});
await rollupBuild.write({
file: 'dist/demo.js',
format: 'iife',
});
await rollupBuild.close();
});
/**
* A gulp task to copy our other demo files to our dist folder
*/
gulp.task('content', () => {
return gulp
.src(['demo/index.html', 'demo/styles.css'])
.pipe(gulpCopy('dist', { prefix: 1 }));
});
/**
* Clean out old content
*/
gulp.task('clean', () => {
return gulp
.src('dist', {
allowEmpty: true,
read: false,
})
.pipe(clean());
});
/**
* Watch for file changes
*/
gulp.task('watch', () => {
gulp.watch('*(src|demo)/**/*.js', gulp.series('js', 'reload'));
gulp.watch('demo/**/*.*(html|css)', gulp.series('content', 'reload'));
});
/**
* Serve files
*/
gulp.task('serve', () => {
browserSync.init({
notify: false,
server: { baseDir: './dist' },
});
});
/**
* Serve updated files
*/
gulp.task('reload', (callback) => {
browserSync.reload();
callback();
});
/**
* Start up gulp
*/
gulp.task(
'default',
gulp.series(
'clean',
gulp.parallel('js', 'content'),
gulp.parallel('serve', 'watch'),
),
);