Deploy any JavaScript front-end app with auto deployment using Git for free ๐!
For many developers, deploying an app becomes a headache, as during the time of shipping, one has to take care of app size, asset compression, redirection rules, etc.
The best approach to this involves, creating the deployment process at the very early stage during development time itself. This helps to clear out production bugs ๐ too soon. Having an auto deployment process will also simplify developers work to a great extent. So in this article let me simplify your work and you focus on development part.
So first requirements here involve having either GitHub or Bitbucket account to host our code. Next we will use Netlify to setup our auto deployment process. Please signup in them and proceed forward.
Now create a repository inside our git account.
Next, push the latest code.
git init
git add .
git commit -m "setting auto-deployment :fire:"
git remote add origin https://github.com/username/reposity_name
git push origin master
Once your code has been pushed, you have finished the main step.
Now comes the best part.
Open Netlify, and press on below button.
Then choose your git provider.
Next choose your git repository and allow Netlify to read the source code. Once that is done, we need to carefully setup the build process.
Build process varies for different JS frameworks.
For Angular:
Build command is ng build --prod
and publish directory is the one mentioned in angular.json file "outputPath": "dist/app"
.
Next you need to setup redirection file. Create a _redirects
file in src/_redirects
path. Add the path to angular.json
file in "assets": [...,"src/_redirects"]
. Add following details to _redirects
file.
/* /index.html 200
Once setup has been done, click on โDeploy siteโ button.
This will go through process of setting up the npm packages required for your projects. Sit back and relax. Let Netlify do its auto deployment job.
If everything goes well you see โsite is liveโ or green signal โ published in Deploys section.
Now for every commit to git, Netlify will auto start the deployment script and create latest commit to your live app as well.
If needed you can also setup custom domain which is also free of cost.
Add CNAME or A record inside DNS provider.
Cheers!!!
No More Worries for Production Bugs of Deployment.
Mexson Fernandes
https://robomx.com โ Tech hub
โThings look simple when theyโre done.โ โ RoboMex