Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
295 views
in Technique[技术] by (71.8m points)

javascript - How can I deploy my react app with parcel bundler to Bluehost server?

So I am attempting to deploy an application built with React and Parcel JS bundler. My question is, if it is not being deployed to Github-pages, but to a server like "BlueHost" for example, Do I upload the "Dist" folder that Parcel bundles after parcel build command?

If so can someone explain how the process works after the "dist" folder is uploaded. How is it able to find "index.html" .

I am just trying to put a react and parcel project onto my portfolio website which is hosted on (BLueHost), don't want to use Github-pages for this particular project.

Hope that made sense? Thanks!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Assuming all the files necessary for your web app are in the dist directory, then yes, that's what you would upload. You will need to serve them with a web server. You could either write a simple server yourself, like this Node example:

const express = require('express')
const app = express()

app.use(express.static(__dirname + '/dist'))
app.listen(8000, () => { console.log('listening') })

Or you could use an existing web server like Nginx, Apache, or Caddy, which you would need to install and configure on your server. Files sitting on a server aren't accessible unless there's a process actually serving them up on a port accessible to the web.

This tool is from DigitalOcean, but is very useful and should help you if you decide to use Nginx on BlueHost.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...