Skip to content
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

[email protected] #1017

Closed
emmanuelballery opened this issue Jul 20, 2021 · 12 comments · Fixed by #1031
Closed

[email protected] #1017

emmanuelballery opened this issue Jul 20, 2021 · 12 comments · Fixed by #1031

Comments

@emmanuelballery
Copy link

emmanuelballery commented Jul 20, 2021

Hi!

[email protected] is released and I encountered 2 errors when installing a new app using Encore :

  1. a doc change : firewall was renamed (reported here [Frontend/Encore] WebpackDevServer 4.0.0-rc.0 renamed the "firewall" option into "allowedHosts" symfony-docs#15542)
  2. there is no host property in the client option see code / see related issue
    image

#1017 (comment) The last one cannot be changed without forcing webpack-dev-server to stay at 4.0.0-beta.3.

Have a nice day!

@tocsinde
Copy link

tocsinde commented Jul 20, 2021

Concerning the second error: I fixed it by using the following code in the webpack.config.js


Encore
    .configureDevServerOptions((options) => {
        
        // hotfix for webpack-dev-server 4.0.0rc0
        // @see: https://github.com/symfony/webpack-encore/issues/951#issuecomment-840719271
        
        delete options.client;
    })

@hailwood
Copy link
Contributor

hailwood commented Jul 25, 2021

Just to add on here, deleting options.client caused my WS connections to fail so I had no hot reloading,
I had to do the following

Encore.configureDevServerOptions(options => ({
    ...options,
    allowedHosts: 'all',
    client: {
      webSocketURL: 'wss://localhost:8080/ws'
    },
}));

@ghost
Copy link

ghost commented Jul 26, 2021

@hailwood it's strange, @tocsinde workaround is working just fine for us, even with websockets and HMR/hot reload

@hailwood
Copy link
Contributor

@mfu-aroche are you accessing your site from a localhost address? E.g. localhost:3000? That would work. My change is needed if you're using a non localhost url like Lando or similar 👍

@bobvandevijver
Copy link
Contributor

I'm using the following configuration, which seems to work just fine:

Encore.configureDevServerOptions(options => {
      options.allowedHosts = 'all';
      options.https = {
        cert: '/etc/apache2/ssl/domain.dev/fullchain.pem',
        key: '/etc/apache2/ssl/domain.dev/privkey.pem',
      };

      delete options.client.host;
    })

The HMR server is access through https://localhost.domain.dev:8999/.

@jkabat
Copy link

jkabat commented Aug 31, 2021

There seems to be more issues when I have encore in separate container as main application.

For [email protected] I had to use "setPublicPath" with absolute path + domain, and setmanifestKeyPrefix. I needed to setup --keep-public-path and --client-web-socket-url also, but for some reason I still cant make hot reloading to work...

I have tried almost anything to get rid "...hot-update.json not found" error...

@Mareva-dev
Copy link

Mareva-dev commented Aug 31, 2021

I've been working on this issue for two days now. I'm using Symfony 5 (webpack-encore) with React JS.

Initially i had the following issue:
image

I tried a lot of things but last one is :

//webpack.config.js
.configureDevServerOptions(options => ({
        ...options,
        allowedHosts: 'all',
        client: {
          webSocketURL: 'wss://localhost:8080/ws'
        },
    })      
    )

But i got
WebSocketClient.js:13 WebSocket connection to 'wss://localhost:8080/ws' failed:
index.js:529 [webpack-dev-server] Event {isTrusted: true, type: "error", target: WebSocket, currentTarget: WebSocket, eventPhase: 2, …}

Could you please explain me how to deal with it ?? I'm getting mad over it

@jkabat
Copy link

jkabat commented Aug 31, 2021

@Mareva-dev webSocketUrl should start with "ws:" not with "wss:".

@weaverryan
Copy link
Member

Hi everyone!

Could I have a few of you hack in the fix from #1031 to see if it works for you?

Thanks!

@leevigraham
Copy link

@weaverryan

setting allowedHosts: 'all', and implementing the fix in #1031 resolved the start up issues for me.

@leevigraham
Copy link

leevigraham commented Sep 2, 2021

@weaverryan My final method looks like:

.configureDevServerOptions((options) => {
    options = {
      ...options,
      // firewall: false,
      allowedHosts: "all",
      host: options.client.host,
      https: {
        key: fs.readFileSync(process.env.SSL_KEY),
        cert: fs.readFileSync(process.env.SSL_CERT),
      },
      // liveReload and static are used to reload the whole page
      // when anything in templates changes
      liveReload: true,
      static: {
        directory: path.resolve(__dirname, "templates"),
        publicPath: "/",
        serveIndex: true,
        watch: true,
      },
    };
    delete options.client.host;
    return options;
  });

This approach also doesn't require the hack in #1031.

@jkabat
Copy link

jkabat commented Sep 2, 2021

I have tried almost anything to get rid "...hot-update.json not found" error...

Seems like I'm running into this issue: https://stackoverflow.com/questions/62974405/webpack-hmr-browser-not-outputting-hot-update-json

When I update an asset (with error in console and browser reloading all the time), files are recompiled and hot-update.json is finally generated. It is not generated when containers are launched for the first time... Any help?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants