You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/content/configuration/watch.md
+28-16
Original file line number
Diff line number
Diff line change
@@ -15,18 +15,20 @@ webpack can watch files and recompile whenever they change. This page explains h
15
15
16
16
## `watch`
17
17
18
-
`boolean`
18
+
`boolean: false`
19
19
20
-
Turn on watch mode. This means that after the initial build, webpack will continue to watch for changes in any of the resolved files. Watch mode is turned off by default:
20
+
Turn on watch mode. This means that after the initial build, webpack will continue to watch for changes in any of the resolved files.
21
21
22
-
```js
22
+
__webpack.config.js__
23
+
24
+
```javascript
23
25
module.exports= {
24
26
//...
25
-
watch:false
27
+
watch:true
26
28
};
27
29
```
28
30
29
-
T> In webpack-dev-server and webpack-dev-middleware watch mode is enabled by default.
31
+
T> In [webpack-dev-server](https://github.com/webpack/webpack-dev-server) and [webpack-dev-middleware](https://github.com/webpack/webpack-dev-middleware) watch mode is enabled by default.
30
32
31
33
32
34
## `watchOptions`
@@ -35,7 +37,9 @@ T> In webpack-dev-server and webpack-dev-middleware watch mode is enabled by def
35
37
36
38
A set of options used to customize watch mode:
37
39
38
-
```js
40
+
__webpack.config.js__
41
+
42
+
```javascript
39
43
module.exports= {
40
44
//...
41
45
watchOptions: {
@@ -48,25 +52,29 @@ module.exports = {
48
52
49
53
## `watchOptions.aggregateTimeout`
50
54
51
-
`number`
55
+
`number: 300`
52
56
53
57
Add a delay before rebuilding once the first file changed. This allows webpack to aggregate any other changes made during this time period into one rebuild. Pass a value in milliseconds:
For some systems, watching many file systems can result in a lot of CPU or memory usage. It is possible to exclude a huge folder like `node_modules`:
68
74
69
-
```js
75
+
__webpack.config.js__
76
+
77
+
```javascript
70
78
module.exports= {
71
79
//...
72
80
watchOptions: {
@@ -77,7 +85,9 @@ module.exports = {
77
85
78
86
It is also possible to have and use multiple [anymatch](https://github.com/micromatch/anymatch) patterns:
79
87
80
-
```js
88
+
__webpack.config.js__
89
+
90
+
```javascript
81
91
module.exports= {
82
92
//...
83
93
watchOptions: {
@@ -91,11 +101,13 @@ T> If you use `require.context`, webpack will watch your entire directory. You w
91
101
92
102
## `watchOptions.poll`
93
103
94
-
`boolean``number`
104
+
`boolean: false``number`
95
105
96
106
Turn on [polling](https://whatis.techtarget.com/definition/polling) by passing `true`, or specifying a poll interval in milliseconds:
97
107
98
-
```js
108
+
__webpack.config.js__
109
+
110
+
```javascript
99
111
module.exports= {
100
112
//...
101
113
watchOptions: {
@@ -109,7 +121,7 @@ T> If watching does not work for you, try out this option. Watching does not wor
109
121
110
122
## `info-verbosity`
111
123
112
-
`string`: `none``info``verbose`
124
+
`string: 'none', 'info', 'verbose'`
113
125
114
126
Controls verbosity of the lifecycle messaging, e.g. the `Started watching files...` log. Setting `info-verbosity` to `verbose` will also message to console at the beginning and the end of incremental build. `info-verbosity` is set to `info` by default.
115
127
@@ -146,9 +158,9 @@ On macOS, folders can get corrupted in certain scenarios. See [this article](htt
146
158
147
159
### Windows Paths
148
160
149
-
Because webpack expects absolute paths for many config options such as `__dirname + "/app/folder"` the Windows `\` path separator can break some functionality.
161
+
Because webpack expects absolute paths for many config options such as `__dirname + '/app/folder'` the Windows `\` path separator can break some functionality.
150
162
151
-
Use the correct separators. I.e. `path.resolve(__dirname, "app/folder")` or `path.join(__dirname, "app", "folder")`.
163
+
Use the correct separators. I.e. `path.resolve(__dirname, 'app/folder')` or `path.join(__dirname, 'app', 'folder')`.
0 commit comments