Skip to content

[Encore] dev-server https fix updates #14930

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
Feb 8, 2021
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
32 changes: 20 additions & 12 deletions frontend/encore/dev-server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,18 @@ you're done: the paths in your templates will automatically point to the dev ser
dev-server Options
------------------

.. caution::

Encore uses ``webpack-dev-server`` version 4, which at the time of Encore's
1.0 release was still in beta and was not documented. See the `4.0 CHANGELOG`_
for changes.

The ``dev-server`` command supports all the options defined by `webpack-dev-server`_.
You can set these options via command line options:

.. code-block:: terminal

$ yarn encore dev-server --https --port 9000
$ yarn encore dev-server --port 9000

You can also set these options using the ``Encore.configureDevServerOptions()``
method in your ``webpack.config.js`` file:
Expand Down Expand Up @@ -58,26 +64,27 @@ If you're using the :doc:`Symfony web server </setup/symfony_server>` locally wi
you'll need to also tell the dev-server to use HTTPS. To do this, you can reuse the Symfony web
server SSL certificate:

.. code-block:: javascript
.. code-block:: diff

// webpack.config.js
// ...
const path = require('path');
+ const path = require('path');

Encore
// ...

.configureDevServerOptions(options => {
options.https = {
pfx: path.join(process.env.HOME, '.symfony/certs/default.p12'),
}
})
+ .configureDevServerOptions(options => {
+ options.https = {
+ pfx: path.join(process.env.HOME, '.symfony/certs/default.p12'),
+ }
+ })

Then make sure you run the ``dev-server`` with the ``--https`` option:

.. code-block:: terminal
.. caution::

$ yarn encore dev-server --https
Make sure to **not** pass the ``--https`` flag at the command line when
running ``encore dev-server``. This flag was required before 1.0, but now
will cause your config to be overridden.

CORS Issues
-----------
Expand Down Expand Up @@ -116,4 +123,5 @@ your page. HMR works automatically with CSS (as long as you're using the
CSS. That is no longer needed.

.. _`webpack-dev-server`: https://webpack.js.org/configuration/dev-server/
.. _`it's not recommended to disable the firewall`: https://webpack.js.org/configuration/dev-server/#devserverdisablehostcheck
.. _`it's not recommended to disable the firewall`: https://webpack.js.org/configuration/dev-server/#devserverdisablehostcheck
.. _`4.0 CHANGELOG`: https://github.com/webpack/webpack-dev-server/blob/master/CHANGELOG.md#400-beta0-2020-11-27