Most of the tutorials on learning React discuss using node and webpack in a dev environment. I'm looking for information on deploying to a production environment. Specifically, how do you create a webpack production server and how do you get it running in your production environment? Thanks
-
You don't actually run webpack on a production server. You create a local production webpack build step that creates all the static files you need. Then you upload the files to your server and serve them like any other files. Further reading http://blog.andrewray.me/webpack-when-to-use-and-why/ – Andy Ray Aug 30 '16 at 17:31
3 Answers
You don't need webpack in production. Just use it to compile your code into a single bundle and you're good to go!
React applications in production only need a single html,a bundle.js(or anything you've named your bundle) and other assets of your project.
And if you're using NodeJs, you'll probably need to find a Host which supports it. For example Heroku

- 760
- 1
- 6
- 19
You can use webpack to compile reactjs in production easily. It always better to use webpack if you know that your project is going to scale up and the number of components are going to increase.
Webpack provides code splitting features which is really cool because when your components grow you dont want to compile all components in single file, you can but that you make it really slow. I would suggest you go through webpack documentation once. It clearly mentions about code splitting and how it should work.
For now I would suggest just use webpack -p
in production to minify and uglify your js. And in case number of components in your projects grow go for code splitting.

- 7,768
- 5
- 47
- 73
You need to add enviroment variables and them you can use webpack to build for dev and prod enviroments.
Checkout a complete reference for this here: Why is my webpack bundle.js and vendor.bundle.js so incredibly big?

- 1
- 1

- 398
- 8
- 18