Deploying an Angular app to Netlify
When you’re deploying an Angular App on Netlify, there are a few config steps to remember.
1. Create _redirects
Put a _redirects file in src, containing this rule:
/* /index.html 200
2. Add it to assets
Add the _redirects file to the assets collection of angular.json:
"assets": [
"src/favicon.ico",
"src/assets",
"src/_redirects"
],
3. Make a prod build task
Set up a production build task in package.json:
"build": "ng build",
"build:prod": "ng b --prod",
4. Use it
In Netlify, configure the build task as npm run build:prod
5. Set publish directory
Set the Netlify ‘Publish directory’ to dist/appName/ (with your app name there. Check the dist folder on your PC after running npm run build if you’re not sure 🙂
Done
That’s it! This reminder article is gonna help me, I hope it helps you too.