How to deploy the build of a electron app like Sizzy? - reactjs

I'm new to yarn, nodejs and react apps. I've tried running the Sizzy app and it works on my local XAMPP server if I first run yarn start in the cmd terminal and then access via http://localhost:3033, but after a while I have to rerun the same command. I've tried yarn build and then navigating to the build directory but that just loaded a page with a header, it didn't have the same functionality. And the contents of the build directory looks very similar to the contents of the public directory anyway.
I've had a look at this SO post and this one but still unsure why I need to run yarn start everytime.
UPDATE:
I'm still not sure how node, react, and electron fit together and why each is required, much research and learning still to do! Rather than a 'react app' I believe I'm looking at an 'Electron app'. I think if I run the command npm run package-win then I think I should get an exe file and some dlls. But how to instead setup for running on an Apache web server without having to start using the command line, or would you just have to build it with different architecture?
Starting to get a vague understanding from reading this.

If you used the npx create-react-app <app-name> then you just have to change the "start" script in the package.json file as "serve -s build". Run yarn add serve to add For deployment, Heroku is a good choice. Create a Heroku app and connect your git repo to the newly created app. Then go to the deploy tab and deploy your branch.

Related

Deploy strapi and react js to heroku

I have strapi as backend and react js as frontend developed in separate folders. When doing the development from localhost I have to run npm start for both strapi and react js which both running in two different port.
The thing is, I've been asked to deploy my project to heroku but I have no idea on the deployment process as there is no specific tutorial that I can find for that matter. I found this similar issue as mine here How to deploy Strapi backend and ReactJS frontend to a single Heroku app but the solutions given are not clear to follow.
Should I put the strapi and react js in one folder and add the middlewares like in the solution given then only deploy?
The first thing you need to do is to get a CLI instalation on your machine. After that you need to Login on heroku with the following command:
$ heroku login
After you've done this step you need to clone the repository or the remote location in case you have already a git repo on your localmachine as such.
Remember that before this you need to create a Heroku App on heroku.com first. then follow the step.
$ heroku git:clone -a [my-repository-name]
after you are done with this. Commit your project files. as such.
$ git add .
$ git commit -m "my first project commit front end"
$ git push heroku master
You need to make sure that you have a procfile that is needed in order to run the npm run command. so.. create a file called.
Procfile
(this is the name of the file that needs to be behind src file.
After you have done this. You may continue with the next project. example. this would work only for your frontend application. For the backend application you can create another application and repeat the same steps.
web: npm run start

Deploying ReactJs app in my machine through localhost

I create a reactJs App. But for now I run this app through Intellij idea and I would like to deploy it and run permanently in my machine without turning on through Intellij idea. How I could deploy react app and run it as deployment in my machine
If you created your app with create-react-app, you should be able to start local development server from the command line. To do this, open you project's root directory in the terminal and type npm start.
If you would like to create and serve a production bundle, you should build your project with npm run build and then serve build directory with a web server. The easiest way to do this is install serve via npm (npm install -g serve) and run serve -s build
For this purpose only webservers available like Tomcat, Payara, Whildfly, etc. You can install any one of those servers and deploy your application into that. As on when you started the server your application will be accessible.
Approach 1:
You can set up the server into your IDE and simply run the project on server mode.
Approach 2:
By using your project code, create a war file with the help of any build tool like MAVEN/GRADLE, etc. Then login into the server manager(Tomcat Manager) and deploy the generated .war file in deployment section.
Note: With the 2nd approach, you can access the application as on when you start the server.

Using create-react-app with "npm run dev"

I am developing a React JS app on a remote server which uses Apache.
In the past I have built a React JS app manually with webpack/babel etc. and then used "npm run dev" to run the app.
With this method I could see any errors on the fly in the terminal and test in the browser automatically through the web browser.
I am now creating a new site with create-react-app which takes care of a lot of the tedious setup for you. One thing I cannot figure out is how to use something similar to "npm run dev". My two options seem to be:
npm run build - This takes a while and I have to rerun it every time I change my code. It does put the updated code in the /build directory which I can link to from my Apache server and see in my browser.
npm start - I can see any errors right away in the terminal, but I cannot see it in my browser because it runs on localhost and does not get compiled to the build directory.
What can I do so that I get the best of both worlds? Having quick rebuilds / error reporting and being able to see remotely through my Apache server?
Or would it be better just to go back to my old manual way of doing things?

What are some ways to deploy a reactjs application

So, I have spent a couples of months learning react and have now created a react app that works nicely on my local computer using the web address localhost:3000. But now is the big question: how do I deploy the app so it becomes accessible on the internet for everybody to see. Previously I have place on a web hotel where I can host some php files. But how do I put the react app on that web hotel. Or do I need some other service that a normal web hotel cannot handle.
Thanks for any help
/Simon :-)
There's a few great options for pushing out your first React application. Once it's built and hosted on GitHub, there's a few free options for deploying static websites (as long as your app meets this requirement). I suggest checking out GitHub Pages (https://pages.github.com/) or Netlify (https://www.netlify.com/); they offer you the tools to deploy right from your repository.
The short answer is simply run npm run build or yarn build command then the scripts try to create a js file and a CSS file and a HTML file and all your files can access from build folder. so just copy build folder and everything in it to server for example upload it to Heroku or AWS
First you should create build. Use 'npm run build' or if you are using yarn then use 'yarn build' command.
After that you will see build folder in your app having html file static folder.
You can test with any local server in your machine. You can use following chrome extension to deploy your app locally. Just import your build folder inside this extension.
Web server for chrome
Thank you Keith!
I used "Github pages" to deploy my React app and it was surprisingly simple. I found a great short 5 minute tutorial on Youtube: "https://www.youtube.com/watch?v=1Y-PqBH-htk". This is how I did it:
Added this line to my package.json file, at the top level:
"homepage": "https://zimon42.github.io/helloworld"
(zimon42 is your username on Github. helloworld is the name of your repository)
Installed the so called Github pages module by running:
npm install --save gh-pages
Added these two lines to my package.json file, under scripts:
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
Committed and pushed everything to Git (Dont know if this step is necessary)
Deploying the application by running
npm run deploy
Now simply check out the paeg at https://zimon42.github.io/helloworld.
( For me there was a delay before the changed took effect.)
Also my routes didn't work. Got a empty page. But saw this video: https://www.youtube.com/watch?v=7yA7BGos2KQ&t=114s which described using HashRoutes instead, and then it worked!
/Simon :-)

React web-page won't display on server

I have been trying to deploy my create-react-app on a server but have been unable to do so. I created a homepage field in the package.json as instructed and set it to the https://... domain address. Then I ran npm run build and created the build file. I am finding resources sparse online, instructing me what to do after. Running npm start just runs from the root directory, not displaying anything. The source shows and index.html file which paths are stuck at the root. I am wondering what I need to do to run/deploy the build(production). I have tried downloading the npm package serve, but this seems to do the same as npm run, if not worse. I feel like I am only moving in the opposite direction, and would love some assistance. Thank you.
You need to run npm build.
This creates files in the build folder.
These files you then need to take and put them in a folder that is served by a web server.
You can use Nginx, Apache, IIS or any other production ready web server.
You have an IT department, ask them where exactly you need to put your files.

Resources