- You have scaffolded your Angular project using Angular CLI
- You have committed the angular project in GIT repo in VSTS.
Goto your package.json and add following command to it
“build-prod”: “ng build –prod –aot”
–aot flag is optional, –prod meta-flag compiles with AOT by default.
Now go to your git project in VSTS online and create a build definition as follows
- Click on Builds and Release from top menu
- This should show create NEW build definition button
- Click on the New button to show the list of available OOB build definitions
- Select Azure Web App and select Apply, this will show the Azure Web App build defintition steps
- Configure the Process tab as per your settings, like Azure subscription, Service Name etc.
- As you can see OOB Azure Web App template has lot of unwanted build steps like Nuget Restore, Building solution etc. We can remove all these build steps and just keep the Azure App Service Deploy
- Now we need to do NPM install and NPM build so for that we add 2 builds steps
- Search for NPM and add it
- Configure NPM build step as shown below and please ensure to configure the “Working folder with package.json” to “$(Build.SourcesDirectory)”
- This will ensure that it does npm install during the build.
- Add one more npm build steps similarly like above, only difference in this case is we will trigger the prod build which we had configures right at the top of the article. Configure the build steps like shown below
- The above npm step is to run custom npm command which is this case is “run build-prod”. As you can recollect in the package.json file we had configured build-prod command.
- Please note that 2 npm steps should be prior to the Azure App Service deploy step.
- Save the build definition and queue the build to verify every thing works as expected.
- Once the build has succeeded you can set up CI/CD, continuous integration and continuous deployment, be default it is disabled
- Enable the continuous integration and configure as below
- This will trigger build and deploy the content for every git commit.