Skip to content

Commit 63e99d8

Browse files
committed
minor #11398 [Frontend] Add doc Watch Options configuration (Kocal)
This PR was submitted for the master branch but it was squashed and merged into the 3.4 branch instead (closes #11398). Discussion ---------- [Frontend] Add doc Watch Options configuration Hi, This PR add a new page that shows how to easily configure watching options with Encore: ```js Encore.configureWatchOptions(watchOptions => { watchOptions.poll = 250; }); ``` I've also reworked the Advanced Config page to remove the old way to configure watch options. Thanks! Commits ------- da27286 [Frontend] Add doc Watch Options configuration
2 parents 9523b7d + da27286 commit 63e99d8

File tree

3 files changed

+19
-12
lines changed

3 files changed

+19
-12
lines changed

frontend.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ Guides
7373
* :doc:`Passing Information from Twig to JavaScript </frontend/encore/server-data>`
7474
* :doc:`webpack-dev-server and Hot Module Replacement (HMR) </frontend/encore/dev-server>`
7575
* :doc:`Adding custom loaders & plugins </frontend/encore/custom-loaders-plugins>`
76+
* :doc:`Configuring Watching Options and Polling </frontend/encore/watch-options>`
7677
* :doc:`Advanced Webpack Configuration </frontend/encore/advanced-config>`
7778

7879
Issues & Questions

frontend/encore/advanced-config.rst

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,8 @@ Summarized, Encore generates the Webpack configuration that's used in your
55
``webpack.config.js`` file. Encore doesn't support adding all of Webpack's
66
`configuration options`_, because many can be added on your own.
77

8-
For example, suppose you need to set `Webpack's watchOptions`_ setting. To do that,
9-
modify the config after fetching it from Encore:
10-
11-
.. TODO update the following config example when https://github.com/symfony/webpack-encore/pull/486 is merged and configureWatchOptions() is introduced
8+
For example, suppose you need to resolve automatically a new extension.
9+
To do that, modify the config after fetching it from Encore:
1210

1311
.. code-block:: javascript
1412
@@ -20,14 +18,9 @@ modify the config after fetching it from Encore:
2018
2119
// fetch the config, then modify it!
2220
var config = Encore.getWebpackConfig();
23-
// if you run 'encore dev --watch'
24-
config.watchOptions = { poll: true, ignored: /node_modules/ };
25-
// if you run 'encore dev-server'
26-
config.devServer.watchOptions = { poll: true, ignored: /node_modules/ };
2721
28-
// other examples: add an alias or extension
29-
// config.resolve.alias.local = path.resolve(__dirname, './resources/src');
30-
// config.resolve.extensions.push('json');
22+
// add an extension
23+
config.resolve.extensions.push('json');
3124
3225
// export the final config
3326
module.exports = config;
@@ -212,6 +205,5 @@ The following loaders are configurable with ``configureLoaderRule()``:
212205
- ``handlebars``
213206

214207
.. _`configuration options`: https://webpack.js.org/configuration/
215-
.. _`Webpack's watchOptions`: https://webpack.js.org/configuration/watch/#watchoptions
216208
.. _`array of configurations`: https://github.com/webpack/docs/wiki/configuration#multiple-configurations
217209
.. _`Karma`: https://karma-runner.github.io

frontend/encore/watch-options.rst

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Configuring Watching Options and Polling
2+
========================================
3+
4+
Encore provides the method ``configureWatchOptions()`` to configure `Watching Options`_ when running ``encore dev --watch`` or ``encore dev-server``:
5+
6+
.. code-block:: javascript
7+
8+
Encore.configureWatchOptions(function(watchOptions) {
9+
// enable polling and check for changes every 250ms
10+
// polling is useful when running Encore inside a Virtual Machine
11+
watchOptions.poll = 250;
12+
});
13+
14+
.. _`Watching Options`: https://webpack.js.org/configuration/watch/#watchoptions

0 commit comments

Comments
 (0)