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

Trouble to start the dev server #630

Open
GuyoST opened this issue Sep 18, 2022 · 2 comments
Open

Trouble to start the dev server #630

GuyoST opened this issue Sep 18, 2022 · 2 comments

Comments

@GuyoST
Copy link

GuyoST commented Sep 18, 2022

Hello every one,

I just installed and configured react-app-rewired, thank you so much because I could split my code as I wanted to.

I had no problem to build the app using npm run build (react-app-rewired build).

But when I try npm start using react-app-rewired start, it stucks on "Starting the development server" and if I try to connect on http://localhost:3000, I get an infinite "pending" on "localhost".

My configuration is working without any trouble when I want to build, I get the app splitted as I wanted and it's working in production.

Here is the configuration if it can helps (just to get one chunk per node_module) :

module.exports = {
    webpack: function override(config, env) {

        config.optimization.runtimeChunk = 'single'

        config.optimization.splitChunks = {
            chunks: 'all',
            maxInitialRequests: Infinity,
            minSize: 0,
            cacheGroups: {
                vendor: {
                    test(module) {
                        return !!module.context && module.context.includes("node_modules")
                    },
                    name(module) {
                        const packageName = module.context.match(/[\\/]node_modules[\\/](.*?)([\\/]|$)/)[1];
                        return `npm.${packageName.replace('@', '')}`;
                    }
                }
            }
        }

        return config;
    },

    devServer: function (configFunction) {
        
        return function (proxy, allowedHost) {
            const config = configFunction(proxy, allowedHost);
            return config;
        };
    },
}

I tried to use react-scripts for npm start and it starts correctly, but I think of course it ignores my code splitting configuration.

So I honestly have no idea if that comes from this react-app-rewired or not, but I post here in case it can help to find a solution for me and for other people who can be in the same situation ?

If you have any advice to get more details to know why it stucks (how to get logs ? or something ?) I would be happy !
If you need more details, just ask me 🙂

I'm using for this project : react 17 and react-script 5.0.1

Thank you

@KoreSamuel
Copy link

the same issue occurred in my project.

@lll000111
Copy link

From the README, check out section "3) Webpack Dev Server"

I hate that section because I have no idea what it is trying to say (why not just give instructions for what to do?), but in any case, I think that section is trying to say that the rewired functionality is not used for dev builds. Unfortunately their instructions for what to do are undecipherable for me (unwilling to put in a day or more of work to find out what they mean, they could just have given simple instructions, no?).

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

No branches or pull requests

3 participants