How do I make styling and fonts work on Heroku - reactjs

I've got a node project with a create-react-app project in a folder called client.
It's setup on Heroku and deploys and works (functionaly) using git push heroku master but none of the styling is active and it's using the wrong fonts.
It all works on localhost.
In the project package.json I have
"heroku-postbuild": "cd client && npm install && npm run build"
and in client package.json
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
Cannot find anything wrong in Heroku setup or logs, or any documentation, at a bit of a loss where to start even looking

Included the css file in index.html

Related

GitHub pages React app deployment not working

For some reason I can't get my React app to consistently deploy to GitHub. Occasionally my custom domain will be removed from the repository's page settings and I'll have to add it again. Other times my readme page will be deployed instead of the React app. Other times nothing happens at all.
When I try and deploy, the settings in my GitHub dashboard are set to use the gh-pages branch, and I try and deploy the changes with npm run deploy. These are my scripts, could someone tell me if I'm doing something wrong? I feel like it should be quite simple.
"scripts": {
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},

Refresh current page automatically when script changes

In recent react app I install nodemon globally and modified package.json to add dev command like this:
"scripts": {
"start": "react-scripts start",
"dev": "nodemon ./app.js",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
I start the app like this npm run dev but problem in any changes the development server start again opening new tab. How I make only current tab refreshed ?
Why not simply use npm start?
react-scripts start sets up the development environment and starts a server, as well as hot module reloading. Read more here.

Blank page on create-react-app when deploy to netlify

I'm trying to deploy create-react-app(which is currently on github) to netlify. after it deployed it shows a blank page.
Netlify configurations i have added:
build command: yarn build,
Publish directory: build
and this is my scripts on package.json
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject",
"predeploy": "npm run build",
"deploy": "gh-pages -d build"
},
I was getting blank page only on mobile devices after deploying on Netlify. It worked after I removed REDUX DEVTOOLS EXTENSION from Redux store.

how to configure a react app for production

I want to deploy my react app to production (using heroku). When the app is deployed, React dev tools indicates that my app is running in development mode
I pushed the application to heroku : https://lesamisdhubert.herokuapp.com/
I tried to set an environment variable :
heroku config:set NODE_ENV=production
however, when I console.log(process.env.NODE_ENV), It returns development
I also tried npm run build before pushing to production but it hasn't worked
here are my scripts in the package.json file :
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
however console.log('node env --->', process.env.NODE_ENV); returns 'development'
Does anybody knows how I can set my react app into production mode ? Is this a problem with npm run build ?
Thanks a lot, I really don't understand where this can come from ...
I replaced in package.json :
"scripts": {
"dev": "react-scripts start",
"start": "serve -s build",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"heroku-postbuild": "npm run build"
}
I also created a new heroku app and it seems to work
When configuring enviroment vars in heroku you have to append REACT_APP_VARIABLENAME and then set its value otherwise you can't have access to the env variable.
take a look at: https://github.com/mars/create-react-app-buildpack#compile-time-configuration
you can do this in the heroku client

Deploying my react app on github

I have a master branch and gh-pages.
I was able to see it on gh-pages when a friend developer of mine walked me through it.
I tried to merge the gh-pages with master to add the styling I did and it messed up the viewable app page of github.
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject",
"precommit": "lint-staged",
"build": "node build.js",
"deploy": "npm run build && git-directory-deploy --directory _build/"
},
"homepage": "https://marianapt.github.io/reduxTable/",
"lint-staged": {
"*.{js,json,css,md}": ["prettier --write", "git add"]
}
thats my package.json
I do npm install to make sure its all updated..
ever since i merged the master and the gh-pages I cant see my application and im back to seeing the readme page. https://marianapt.github.io/reduxTable/ thats the link...
I don't understand realy whats happened with you but I think the problem is you lose your prod app.js of master branch when you do the merge.
Just try to run npm run build and push again to the github
Hope this will helps you.

Resources