@@ -29,10 +29,12 @@ function css(cb) {
29
29
cb ();
30
30
}
31
31
32
- // You can use a single task
33
- watch (' src/*.css' , css);
34
- // Or a composed task
35
- watch (' src/*.js' , series (clean, javascript));
32
+ exports .default = function () {
33
+ // You can use a single task
34
+ watch (' src/*.css' , css);
35
+ // Or a composed task
36
+ watch (' src/*.js' , series (clean, javascript));
37
+ };
36
38
```
37
39
38
40
## Warning: avoid synchronous
@@ -49,11 +51,13 @@ If you need to use different events, you can use the `events` option when callin
49
51
``` js
50
52
const { watch } = require (' gulp' );
51
53
52
- // All events will be watched
53
- watch (' src/*.js' , { events: ' all' }, function (cb ) {
54
- // body omitted
55
- cb ();
56
- });
54
+ exports .default = function () {
55
+ // All events will be watched
56
+ watch (' src/*.js' , { events: ' all' }, function (cb ) {
57
+ // body omitted
58
+ cb ();
59
+ });
60
+ };
57
61
```
58
62
59
63
## Initial execution
@@ -65,11 +69,13 @@ To execute tasks before the first file change, set the `ignoreInitial` option to
65
69
``` js
66
70
const { watch } = require (' gulp' );
67
71
68
- // The task will be executed upon startup
69
- watch (' src/*.js' , { ignoreInitial: false }, function (cb ) {
70
- // body omitted
71
- cb ();
72
- });
72
+ exports .default = function () {
73
+ // The task will be executed upon startup
74
+ watch (' src/*.js' , { ignoreInitial: false }, function (cb ) {
75
+ // body omitted
76
+ cb ();
77
+ });
78
+ };
73
79
```
74
80
75
81
## Queueing
@@ -81,11 +87,13 @@ To disable queueing, set the `queue` option to `false`.
81
87
``` js
82
88
const { watch } = require (' gulp' );
83
89
84
- // The task will be run (concurrently) for every change made
85
- watch (' src/*.js' , { queue: false }, function (cb ) {
86
- // body omitted
87
- cb ();
88
- });
90
+ exports .default = function () {
91
+ // The task will be run (concurrently) for every change made
92
+ watch (' src/*.js' , { queue: false }, function (cb ) {
93
+ // body omitted
94
+ cb ();
95
+ });
96
+ };
89
97
```
90
98
91
99
## Delay
@@ -97,11 +105,13 @@ To adjust the delay duration, set the `delay` option to a positive integer.
97
105
``` js
98
106
const { watch } = require (' gulp' );
99
107
100
- // The task won't be run until 500ms have elapsed since the first change
101
- watch (' src/*.js' , { delay: 500 }, function (cb ) {
102
- // body omitted
103
- cb ();
104
- });
108
+ exports .default = function () {
109
+ // The task won't be run until 500ms have elapsed since the first change
110
+ watch (' src/*.js' , { delay: 500 }, function (cb ) {
111
+ // body omitted
112
+ cb ();
113
+ });
114
+ };
105
115
```
106
116
107
117
## Using the watcher instance
0 commit comments