Skip to content

Commit cc2bf10

Browse files
committed
Merge branch '3.4' into 4.2
* 3.4: [Frontend] Add doc Watch Options configuration
2 parents 7c8edfc + 9657ac2 commit cc2bf10

File tree

1 file changed

+19
-12
lines changed

1 file changed

+19
-12
lines changed

frontend/encore/advanced-config.rst

Lines changed: 19 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;
@@ -45,6 +38,20 @@ But be careful not to accidentally override any config from Encore:
4538
// BAD - this replaces any extensions added by Encore
4639
// config.resolve.extensions = ['json'];
4740
41+
Configuring Watching Options and Polling
42+
----------------------------------------
43+
44+
Encore provides the method ``configureWatchOptions()`` to configure
45+
`Watching Options`_ when running ``encore dev --watch`` or ``encore dev-server``:
46+
47+
.. code-block:: javascript
48+
49+
Encore.configureWatchOptions(function(watchOptions) {
50+
// enable polling and check for changes every 250ms
51+
// polling is useful when running Encore inside a Virtual Machine
52+
watchOptions.poll = 250;
53+
});
54+
4855
Defining Multiple Webpack Configurations
4956
----------------------------------------
5057

@@ -212,6 +219,6 @@ The following loaders are configurable with ``configureLoaderRule()``:
212219
- ``handlebars``
213220

214221
.. _`configuration options`: https://webpack.js.org/configuration/
215-
.. _`Webpack's watchOptions`: https://webpack.js.org/configuration/watch/#watchoptions
216222
.. _`array of configurations`: https://github.com/webpack/docs/wiki/configuration#multiple-configurations
217223
.. _`Karma`: https://karma-runner.github.io
224+
.. _`Watching Options`: https://webpack.js.org/configuration/watch/#watchoptions

0 commit comments

Comments
 (0)