简体   繁体   English

Angular 应用程序构建管道 - VSTS 中的持续集成

[英]Angular Application Build pipeline - Continuous Integration in VSTS

Actually I have my angular application required to deploy into Azure.实际上,我需要将 angular 应用程序部署到 Azure 中。 Honestly its my first time deployment with Angular app.老实说,这是我第一次使用 Angular 应用程序进行部署。 So what I choose was Node with Grunt template.所以我选择的是带有 Grunt 模板的 Node。

Here are the steps以下是步骤

steps:
- task: Npm@1
  displayName: 'npm install'
  inputs:
    workingDir: CrSPA/Clientapp
    verbose: false
steps:
- task: Npm@1
  displayName: 'Build Project'
  inputs:
    command: custom
    workingDir: CrSPA/Clientapp
    verbose: false
    customCommand: 'run build-prod'

run build-prod means ng build --prod运行 build-prod意味着ng build --prod

My question is it it the correct approach.我的问题是它是正确的方法。 I asked this because when ever a small change in application, whole npm install procedure takes place and its taking long time to finish.我问这个是因为当应用程序发生小的变化时,整个 npm 安装过程都会发生,并且需要很长时间才能完成。 So I'm not sure the way I'm following is the best way.所以我不确定我遵循的方式是最好的方式。

Also it it best to push after build locally?最好在本地构建后推送? Also is it OK to push node_modules folder as well into repository, So I cant do an npm install always?也可以将 node_modules 文件夹也推送到存储库中,所以我不能总是安装 npm吗?

Your approach is good and you should always do a npm i and ng build --prod on the pipeline before the files get in to the repo.您的方法很好,在文件进入存储库之前,您应该始终在管道上执行npm ing build --prod

This is because when multiple people who work on the same application if they add a new package if you don't do npm install your pipline build will fail.这是因为当多人在同一个应用程序上工作时,如果他们添加一个新的package如果你不做npm install你的管道构建将失败。 So it is always recommended to do所以总是建议这样做

1. npm install
2. ng build --prod

You can read more on this article你可以阅读更多关于这篇文章

Actually it is a good practice to do the dependencies whenever you do the deployment,实际上,在进行部署时执行依赖项是一个好习惯,

You can easily specify and change which version of these packages you depend on in the package json so that you will not have any issues in the environment you deploy and your build will use exact package version listed in the JSON file. You can easily specify and change which version of these packages you depend on in the package json so that you will not have any issues in the environment you deploy and your build will use exact package version listed in the JSON file.

Also it is better to use npm ci instead of npm i because it uses the package lock file with exact version numbers so you will always use exactly correct versions.此外,最好使用npm ci而不是npm i ,因为它使用 package 锁定文件和确切的版本号,因此您将始终使用完全正确的版本。

Here is a good explanation on why you should not include node_modules to commit and as well as build这是一个很好的解释,为什么你不应该包含node_modules来提交和构建

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 VSTS持续集成 - ASP.NET Core和Angular 4项目 - VSTS Continuous Integration - ASP.NET Core and Angular 4 project 具有多环境Azure的VSTS中Angular4应用程序的CI CD管道 - CI CD Pipeline for Angular4 Application in VSTS with Multiple Environment Azure 使用来自 git 或 gitLab 的持续集成部署 Angular 应用程序 - Deploying An Angular application using continuous integration from git or gitLab 使用VSTS管道创建Angular Docker镜像时出现问题 - Issue in creating Angular Docker Image with VSTS Pipeline Visual Studio在线持续集成Angular2 - Visual Studio Online Continuous Integration Angular2 将Angular 5升级到6后出现错误,VSTS构建 - Error after upgrading Angular 5 to 6 , VSTS build Moodle与角度应用程序集成 - Moodle integration with angular application 如何在Gitlab上使用Angular为ASP.NET Core Web应用程序建立构建和测试管道? - How to set up a build and test pipeline for ASP.NET Core Web Application with Angular on Gitlab? VSTS 构建 - 在发布阶段替换 Angular4 环境变量 - VSTS build - replace Angular4 environment variables in Release stage Sonarqube VSTS构建任务构建角度/打字稿项目 - Sonarqube VSTS build task building angular/typescript project
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM