I'm trying to find information online about how to deploy an angular2 with webpack app to azure, but I couldn't find anything helpful enough. I checked the start package as suggested here How do you deploy Angular 2 apps? but I also couldn't find much help there.
So, I have an angular2 app running with webpack locally. It's working perfectly locally. But how do I deploy it to Azure Web Apps?
I appreciate any help :)
Thanks!
Well, so I was able to get it working. After researching I found out there are a few options to go by, mainly creating your own local prod build and uploading it and using CD/CI. I went with the latter. It took quite some time, but now it's all set I don't have to worry about it anymore...
I based myself in this tutorial http://tattoocoder.com/angular2-azure-codeship-angularcli/ by Shane Boyer but since link-only answers are discouraged I'm going to write it here.
Here's how I did it:
Create a free account on CodeShip and import the GitHub repo
On Configure Project
select I want to create my custom commands
and use this code:
nvm install 4.1
npm install angular-cli
npm install
ng serve &
ng e2e
ng build -prod
Save and go to dashboard
Deployment Options > Choose Source > Local Git Repository
Deployment Credentials
and insert the user/password you prefer
Overview
and copy your Git clone url
Project settings > Environment variables
and add AZURE_REPO_URL
with the value being the git clone url you copied with the user/password (https://username:[email protected](...).git
):
Deployment
on the left navigation menuCustom Script
git config --global user.email "[email protected]" git config --global user.name "Your name" git clone $AZURE_REPO_URL repofolder cd repofolder rm -rf * cp -rf ~/clone/dist/* . git add -A git commit --all --author "$CI_COMMITTER_NAME <$CI_COMMITTER_EMAIL>" --message "$CI_MESSAGE ($CI_BUILD_URL)" git push origin master
That was it. Now every time you push to GitHub CodeShip will build your code and every time you PR to release it will build AND publish to azure.
Thank https://stackoverflow.com/users/595213/shayne-boyer for this.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With