Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
311 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 Answer

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...