Skip to content

[Encore] Webpack Dev Server: live reload & HMR #18538

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 20, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions frontend/encore/dev-server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,34 @@ your page. HMR works automatically with CSS (as long as you're using the
``dev-server`` and Encore 1.0 or higher) but only works with some JavaScript
(like :doc:`Vue.js </frontend/encore/vuejs>`).

Live Reloading when changing PHP / Twig Files
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

To utilize the HMR superpower along with live reload for your PHP code and
templates, set the following options:


.. code-block:: javascript

// webpack.config.js
// ...

Encore
// ...

.configureDevServerOptions(options => {
options.liveReload = true;
options.static = {
watch: false
};
options.watchFiles = {
paths: ['src/**/*.php', 'templates/**/*'],
};
})

The ``static.watch`` option is required to disable the default reloading of
files from the static directory, as those files are already handled by HMR.

.. versionadded:: 1.0.0

Before Encore 1.0, you needed to pass a ``--hot`` flag at the command line
Expand Down