0

Webpack how to build production code and how to use it

  • Above question came very near to answering this. But I am stressing on the second part.
  • I am new to Nodejs let alone Webpack. I tried this tutorial https://blog.risingstack.com/using-react-with-webpack-tutorial/ Which really threw light into many aspects of Webpack.
  • But, what I want is a build which can run "on its own", that is, without node modules and other unnecessary files.

  • I tried Webpack -p with production configuration and that runs fine and creates a dist directory. And I thought that directory was what I was looking for. But I can't find a way to run it.

  • What am I missing ?

EDIT:

  • I tried to run means i tried to open the index.html
  • I looked at the browser console now and its showing file not found for both my JS file and CSS file.

  • I will provide a screenshot of the console output. My dist directory contains four files index.html, main-d9103c44e6f452183f46.min.css, main-d9103c44e6f452183f46.min.js, webpack.stats.json.

  • As I mentioned above, pretty much a noob. If you tell me what information I should provide, I'll be happy to provide that. Thank you.

enter image description here

5
  • Are you trying to run this on the server with node? or on a client's browser? Webpack is usually used to generate files that are served to browsers. Commented Jun 30, 2016 at 14:56
  • I ran the app in a virtualbox successfully using npm start. Then I made a production build and tried to run the files in dist folder separately using a browser in my local. And it didn't work. Commented Jun 30, 2016 at 15:09
  • Gonna need a lot more info. What error messages are you getting? What exactly did you do when you say you "tried to run" it? More detail is always helpful. Commented Jun 30, 2016 at 15:15
  • 1
    dist should contain everything you need run the application, including an index.html file that contains a relative path to your bundle.js that was generated. Now that we have index.html and bundle.js, that's all we need. Take a peek here: github.com/mikechabot/react-boilerplate Commented Jun 30, 2016 at 19:12
  • The react boilerplate is working as expected Commented Jul 1, 2016 at 6:28

0

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.