-
-
Notifications
You must be signed in to change notification settings - Fork 601
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
serve does not work with multi-server #2408
Comments
yep, because it is impossible, each compiler should have unique port, it is limitation, you can use multi entry syntax:
Even more - I don't think it is real can be solved, we don't know your files after compilation, and |
Well, multiple entries wouldn't work in our case, since that wouldn't allow us to specify the correct I am a bit confused why this no longer works, since this worked just fine in webpack@4 and I am honestly a bit uncertain as to what our upgrade path can be. |
@Christian24 Can you provide example with webpack@4? I want to look at this, maybe be I am don't understand you correctly |
@alexander-akait sure. https://github.com/Christian24/webpack-dev-server-multi-config/tree/main This should give you a very basic example of what we are doing with webpack4 at the moment, but I am unable to recreate using webpack5. If you need additional details, please let me know. |
@Christian24 hm, works fine with webpack v5 and webpack-cli v4, my command is |
Here some architecture limitations, because And here your case - you need apply webpack-dev-server on multi compiler level and set the In future we will fix this limitation |
First of all thank you, @alexander-akait! You are very right that my example works fine with webpack5, I just checked. However, you were also correct that the multiple To everyone running into the same issue I have adapted my initial example into a
Is it just me or is the the multi-compiler feature lacking documentation? I would be happy to help if hands are needed with that, since it is an invaluable feature for me. |
I do not want to reinvent the wheel, but wouldn't a syntax like {
devServer: ...,
configurations: [...]
} be nicer since it would make make more explicit what part of the configuration is shared globally? |
@Christian24 Yep, I think it should be like this, but changing syntax in config files will be a big problem, I need think about it |
Let's keep open, I want to search right way for this or update docs with the limitation (official) |
Sure, maybe here: https://webpack.js.org/configuration/configuration-types/#exporting-multiple-configurations? I wouldn't know if I would find it there though. I think the whole topic might need more documentation or is there more? Would it be a good idea to open an issue at https://github.com/webpack/webpack.js.org? |
I will open an issue in docs repo don't worry, I need time to think how we can make it better |
@Christian24 @alexander-akait, thanks for your work on this issue!!!! This same problem just came up for me this week. @Christian24's detailed notes helped me get our local dev up and running again! 🙏 |
I think we will do the same webpack/webpack#12671, but for dev server |
I get this same problem now when I try to upgrade As @Christian24's detail, I have also use the multiple configs: https://webpack.js.org/configuration/configuration-types/#exporting-multiple-configurations, and works well on
Thanks all of you! |
@1950195 that is because you have multiple |
Yes, agree. I’m trying to separate the different projects from one webpack config file now. Then may easy to merge some in one... And also we have performance problems on running the build script, about 50 configs in one config. So it’s the time to separate them.😂 |
Thanks for your works, this is my script to remove the same devServers configs. const glob = require('glob');
const util = require('util');
const configs = glob.sync('./plugins/*/webpack.config*.js').map(file => require(file));
if (!process.argv.includes('--config-name')) {
// Remove same devServers to avoid
// "Error: Unique ports must be specified for each devServer option in your webpack configuration."
// @link https://github.com/webpack/webpack-cli/issues/2408
const devServers = [];
configs.forEach(config => {
devServers.forEach(devServer => {
if (util.isDeepStrictEqual(config.devServer, devServer)) {
delete config.devServer;
}
});
if (config.devServer) {
devServers.push(config.devServer);
}
});
}
module.exports = configs; |
We need:
|
This issue had no activity for at least half a year. It's subject to automatic issue closing if there is no activity in the next 15 days. |
bump |
Issue was closed because of inactivity. If you think this is still a valid issue, please file a new issue with additional information. |
@webpack/cli-team I think we can implement it in better way - |
@alexander-akait any update on this? |
No, we need implement plugin support for devserver |
Describe the bug
We're having issues updating to webpack 5 and
webpack serve
. Our project is divided into multiple webpack configurations. Say for example we have one configuration for a SPA/login/
,/portal/
, our application for end users and/admin/
for our administrators. We do this, so that every SPA when hosted belongs into its own folder and we can easily make sure that critical code like in our/admin/
SPA is never served outside of intranet. Now to test locally, we use webpack-dev-server's multi project configuration. Every SPA is identifiable by an uniquepublicPath
(e. g./admin
). This worked beautifully with webpack-dev-server, but with webpack 5 and webpack-cli this is no longer the case. We use multiple webpack configurations to test ourWe used to use
webpack-dev-server
to start our development server directly, however as I understand that is no longer working with webpack 5.What is the current behavior?
Webpack-cli outputs a an error message:
To Reproduce
Steps to reproduce the behavior:
https://github.com/webpack/webpack-cli/blob/master/test/serve/basic/multi-dev-server.config.js without the explicit ports does show my use case perfectly.
Expected behavior
If
publicPath
s for configurations are unique,webpack serve
should be able to serve them from the same port.Screenshots
Please paste the results of
webpack-cli info
here, and mention other relevant informationAdditional context
Maybe this was first introduced with #1649 A possible solution might be to change
webpack-cli/packages/serve/src/startDevServer.ts
Line 14 in ec3baa8
publicPath
s if ports are not unique.Thanks a lot,
Christian
The text was updated successfully, but these errors were encountered: