2

I have the following structure in my react project

  --project
      |
      --main
         |
         -- public
             |
              -- index.html
         -- src
             |
              -- index.js
         webpack.dev.config.js
         webpack.prod.config.js
      -- node_modules
      -- package.json

For the above structure, when I run npm start, I am getting below error

Could not find a required file. Name: index.html Searched in: C:\xampp\htdocs\project\public

because the public folder is there inside main folder. How can I run the code? Please tell me.

EDIT

  output: {
    filename: 'js/[name].js',
    path: path.resolve('/main/public/'),
    publicPath: '/main/public'
  }

tried setting the path in webpack

4
  • You should change the public path in webpack.prod.config.js: github.com/coryhouse/react-slingshot/blob/master/… Commented Jun 26, 2018 at 7:24
  • Please check my question. I have updated it Commented Jun 26, 2018 at 10:18
  • Why only in webpack.prod? Why can't in webpack.dev? Of course I tried both and it's not working. Commented Jun 26, 2018 at 10:24
  • @Mr_Perfect did you solve your problem? I"m struggling with the same issue. Commented May 25, 2022 at 18:43

1 Answer 1

1

You should change the public path in webpack.prod.config.js: https://github.com/coryhouse/react-slingshot/blob/master/webpack.config.prod.js#L23

Sign up to request clarification or add additional context in comments.

2 Comments

Please tell me what should be the path based on my directory. Because I tried, and it's not working. I think I should setup in webpack.dev.config.js
Why only in webpack.prod? Why can't in webpack.dev? Of course I tried both and it's not working.

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.