简体   繁体   中英

How to deploy js in production?

I am React js beginner so I wanted to clarify some things.

Q1. The only way to use React in production is to use webpack-dev-serve ?

Q2. In case that you use webpack-dev-server I should create multiple API which will handle multiple functionalities as another service or microservice ?

Q3. Should you learn node js for further development ? Or it's enough to have knowledge in webpack ?

Thank you in advance!

This is a very good article describing almost all what you need to know about Webpack for bundling you React app .

Since you created the app already, you can scroll down to the required packages installation part in the article.

The answer to 1. is no, it's not meant to serve production code.

The answer to 2 and 3: there are many ways to deploy a React app, and the right answer for you is..... it depends. Some of those don't require you to learn node (or anything to set up a server). The React docs actually provide a lot of the ways to start: https://facebook.github.io/create-react-app/docs/deployment#github-pages-https-pagesgithubcom

If you have an lightweight page, I would recommend something like Github pages or comparable: https://github.com/gitname/react-gh-pages

For reference, here's a React project I built for a coding interview: https://github.com/pink-cupcakes/connect-four

And here is the deployed site via Github pages: https://pink-cupcakes.github.io/connect-four/

But if you deploy a project with a compiled bundle.js, you can actually just open your index.html and it'll run all of your React goodness. Then your question just becomes - how do you deploy a server, and there are many options for that: Heroku, Azure/AWS.

If that sounds like a headache - take a gander at serverless! (Devops magic - automated) https://dev.to/adnanrahic/a-crash-course-on-serverless-side-rendering-with-reactjs-nextjs-and-aws-lambda-13ed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM