Deploying An Angular application using continuous integration from git or gitLab

12,157

Solution 1

If you are using angular cli to building the application, then its pretty straight forward to do the same via jenkins/teamcity.

Install node js on jenkins - https://wiki.jenkins.io/display/JENKINS/NodeJS+Plugin Further you can follow this blog - https://blog.couchbase.com/create-continuous-deployment-pipeline-nodejs-jenkins/

Specific to angular 2/4/5 -You just need to pass the angular CLI commands via shell script and push the build generated towards the desired server.

Something like - ng build With that you can use following flags as well 1. '--prod' - reduces the build size considerably, as it eliminates dead code while using tree shaking 2. '--build-optimizer' - it performs further code optimization, e.g removing decorators etc (works with angular 5, CLI 1.5)

Command will look something like - ng build --prod --build-optimizer

For more in-depth you can read wiki - https://github.com/angular/angular-cli/wiki/build

Solution 2

With the combination of serverless framework and aws s3 storage it's more easy to deploy your angular applications, need not to worry much about webpack. Single command should take care of everything. npm run build: serverless : deploy

For more information : https://serverless.com/framework/docs/providers/aws/guide/deploying/

these commands you can add to any CD tool.

Share:
12,157
Akshay Vijay Jain
Author by

Akshay Vijay Jain

curious learner

Updated on August 21, 2022

Comments

  • Akshay Vijay Jain
    Akshay Vijay Jain almost 2 years

    I am looking to deploy Angular 5 application with continuous integration from bitbucket on an Apache server

    Now because I am new to the field, I am unaware of the possible options to do this

    Like do we need to integrate webpack with Jenkins, or do we need to write some other code on Jenkins, or we can do it without Jenkins and do we need to integrate it along with Sonar

    Some pages do not give any clue about webpack, while some say you just have to write webpack script in Jenkins

    Anyone having experience in this, please enlighten us