diff --git a/frontend.rst b/frontend.rst index f233cfe0016..3fe2686e249 100644 --- a/frontend.rst +++ b/frontend.rst @@ -73,6 +73,7 @@ Guides * :doc:`Passing Information from Twig to JavaScript ` * :doc:`webpack-dev-server and Hot Module Replacement (HMR) ` * :doc:`Adding custom loaders & plugins ` +* :doc:`Configuring Watching Options and Polling ` * :doc:`Advanced Webpack Configuration ` Issues & Questions diff --git a/frontend/encore/advanced-config.rst b/frontend/encore/advanced-config.rst index d901b78d767..7f984a3d642 100644 --- a/frontend/encore/advanced-config.rst +++ b/frontend/encore/advanced-config.rst @@ -5,10 +5,8 @@ Summarized, Encore generates the Webpack configuration that's used in your ``webpack.config.js`` file. Encore doesn't support adding all of Webpack's `configuration options`_, because many can be added on your own. -For example, suppose you need to set `Webpack's watchOptions`_ setting. To do that, -modify the config after fetching it from Encore: - -.. TODO update the following config example when https://github.com/symfony/webpack-encore/pull/486 is merged and configureWatchOptions() is introduced +For example, suppose you need to resolve automatically a new extension. +To do that, modify the config after fetching it from Encore: .. code-block:: javascript @@ -20,14 +18,9 @@ modify the config after fetching it from Encore: // fetch the config, then modify it! var config = Encore.getWebpackConfig(); - // if you run 'encore dev --watch' - config.watchOptions = { poll: true, ignored: /node_modules/ }; - // if you run 'encore dev-server' - config.devServer.watchOptions = { poll: true, ignored: /node_modules/ }; - // other examples: add an alias or extension - // config.resolve.alias.local = path.resolve(__dirname, './resources/src'); - // config.resolve.extensions.push('json'); + // add an extension + config.resolve.extensions.push('json'); // export the final config module.exports = config; @@ -212,6 +205,5 @@ The following loaders are configurable with ``configureLoaderRule()``: - ``handlebars`` .. _`configuration options`: https://webpack.js.org/configuration/ -.. _`Webpack's watchOptions`: https://webpack.js.org/configuration/watch/#watchoptions .. _`array of configurations`: https://github.com/webpack/docs/wiki/configuration#multiple-configurations .. _`Karma`: https://karma-runner.github.io diff --git a/frontend/encore/watch-options.rst b/frontend/encore/watch-options.rst new file mode 100644 index 00000000000..59b91bfedb0 --- /dev/null +++ b/frontend/encore/watch-options.rst @@ -0,0 +1,14 @@ +Configuring Watching Options and Polling +======================================== + +Encore provides the method ``configureWatchOptions()`` to configure `Watching Options`_ when running ``encore dev --watch`` or ``encore dev-server``: + +.. code-block:: javascript + + Encore.configureWatchOptions(function(watchOptions) { + // enable polling and check for changes every 250ms + // polling is useful when running Encore inside a Virtual Machine + watchOptions.poll = 250; + }); + +.. _`Watching Options`: https://webpack.js.org/configuration/watch/#watchoptions