-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
onBeforeSetupMiddleware server isn't accessible #3121
Comments
hm, it is private API, why you need this? |
hi @alexander-akait, |
If you want to keep this API private, we could maybe add an option to handle this case internally ? |
hm, we can implement option |
That would be awesome and cleaner for sure 😄 |
webpack-dev-server/lib/Server.js Line 989 in cd39491
|
Yep, easy to implement, just pass this options to |
got it, thanks |
Can I help you ? |
Thanks but PR is ready 😄 |
Can't believe how fast this feature as been implemented, thank you guys ❤️ |
Anyway you can fix your code (should work): onBeforeSetupMiddleware(devServer) {
const files = [
path.resolve(rootFolder, 'resources/views/**/*.html.twig'),
path.resolve(rootFolder, 'content/collections/**/*.md')
]
// Reload the browser on content/template files change
chokidar.watch(files).on('all', () => {
devServer.sockWrite(sockets, 'content-changed')
})
}, |
Hey @alexander-akait in the above code
Anyway, I can totally wait for a new release with the merge PR to use this feature now 😄 ! |
|
The new release seems not work for me. I tried the sockWrite option,but the this.socketServer seems to be undefined. sockWrite(sockets, type, data) {
sockets.forEach((socket) => {
this.socketServer.send(socket, JSON.stringify({ type, data }));
});
} |
@flyyang because you need wait when socket server starts |
Perfectly working ! Thank you so much @alexander-akait / @anshumanv ❤️ |
FYI if anyone is here with this question on version 4.2.1,
|
Why you use internal API? |
Live reload federated micro-app in host application:
|
we have built-in |
I'll check it out, thanks! |
To get it to work with |
When I am using this code and changing anything in HTML it refreshes the page instead of HMR?
|
Operating System: MacOS v11.2.3
Node Version: v15.12.0
NPM Version: v7.7.5
webpack Version: v5.28.0
webpack-dev-server Version: v4.0.0-beta.1
Browser: Chrome ARM v89.0.4389.90
This is a bug
This is a modification request
Code
When I was using
webpack-dev-server v3
, I was configuring the before option like below.Since I've upgrade to
webpack-dev-server v4.0.0-beta.1
this is not working even if I've follow the release notes.I'm getting an error :
TypeError: Cannot read property 'sockWrite' of undefined
I've looked at the source code to understand how the new
onBeforeSetupMiddleware
but sadly, nothing I've tried worked...Any help would really appreciated, thank you 😅 !
The text was updated successfully, but these errors were encountered: