10000 minor #18538 [Encore] Webpack Dev Server: live reload & HMR (ne0-cz) · symfony/symfony-docs@60c277d · GitHub
[go: up one dir, main page]

Skip to content

Commit 60c277d

Browse files
committed
minor #18538 [Encore] Webpack Dev Server: live reload & HMR (ne0-cz)
This PR was squashed before being merged into the 5.4 branch. Discussion ---------- [Encore] Webpack Dev Server: live reload & HMR To use both live reload and HMR, some options are required and I think the docs would be a perfect place to find them. Commits ------- 0b3ff04 [Encore] Webpack Dev Server: live reload & HMR
2 parents 53acc81 + 0b3ff04 commit 60c277d

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

frontend/encore/dev-server.rst

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,34 @@ your page. HMR works automatically with CSS (as long as you're using the
128128
``dev-server`` and Encore 1.0 or higher) but only works with some JavaScript
129129
(like :doc:`Vue.js </frontend/encore/vuejs>`).
130130

131+
Live Reloading when changing PHP / Twig Files
132+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
133+
134+
To utilize the HMR superpower along with live reload for your PHP code and
135+
templates, set the following options:
136+
137+
138+
.. code-block:: javascript
139+
140+
// webpack.config.js
141+
// ...
142+
143+
Encore
144+
// ...
145+
146+
.configureDevServerOptions(options => {
147+
options.liveReload = true;
148+
options.static = {
149+
watch: false
150+
};
151+
options.watchFiles = {
152+
paths: ['src/**/*.php', 'templates/**/*'],
153+
};
154+
})
155+
156+
The ``static.watch`` option is required to disable the default reloading of
157+
files from the static directory, as those files are already handled by HMR.
158+
131159
.. versionadded:: 1.0.0
132160

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

0 commit comments

Comments
 (0)
0