1

In our old .jsp application, we are integrating react.

My react dev server is running on http://localhost:3000 and existing application at http://localhost:8100.

I included all the required js & CSS files of reacting into JSP page. which is working fine.

When when I'm using lazy-loading in React, for ex:

import('some-file.js').then(file => {
   // Some work
});

In this case Webpack is trying to load chunk from localhost:8100 instead of Dev server.

I'm using react-script for development and build.

enter image description here

5
  • could please try to add in module.exports { output:{publicPath: ' "localhost:3000/static/js/dist or http:/0.0.0.0:3000/dist"'} } in webpack.config.js file and check whether it works or not??? Commented May 9, 2020 at 13:47
  • Its http:/locallhost:3000/dist in the above comment Commented May 9, 2020 at 13:53
  • did above thing works?? Commented May 9, 2020 at 14:21
  • Thanks SAI for quick reply. Let me verify. Commented May 9, 2020 at 14:53
  • Thanks PALLAMOLLA SAI, your Idea works. I fixed it by setting publicPath: "http:localhost:3000". Commented May 9, 2020 at 15:13

1 Answer 1

2

Try to add publicPath like below in webconfig.js files.

output: {
        //
        publicPath: 'http://localhost:3000/static/js/dist' or
        // publicPath : 'http://localhost:3000/dist'
    }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.