[英]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 i
和ng 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
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.