简体   繁体   English

生成构建后如何将 Angular dist 内容复制到另一个位置?

[英]How to copy Angular dist content to another location after generating the build?

使用 ng build 生成构建后,如何自动将文件从 dist 文件夹复制到另一个位置?

Update the package.json file to add更新 package.json 文件以添加

"postbuild":"xcopy /s \".\/dist\" \"my\\folder\\path\" \/Y",

in the scripts object, replace the my/folder/path with your destination path.在脚本对象中,将my/folder/path替换为您的目标路径。

/Y will not ask in the prompt to overwrite files. /Y 不会在提示中要求覆盖文件。

Now run现在运行

npm run build

After the build the content of the dist will be copied to the folder.构建完成后,dist 的内容将被复制到文件夹中。

Alternatively, you change the value of outputPath in angular.json.或者,您可以更改 angular.json 中 outputPath 的值。 Note: This is path where angular puts build artifacts.注意:这是 angular 放置构建工件的路径。 You will no longer see dist/yourProjectName to have been updated as the artifacts directly go to your given path.您将不再看到 dist/yourProjectName 已更新,因为工件直接转到您的给定路径。 Below is excerpt of angular.json以下是 angular.json 的摘录

"architect": {
    "build": {
      "builder": "@angular-devkit/build-angular:browser",
      "options": {
        "outputPath": "../../../../BackEnd/NodeJs/hostAngularProjectOnNodeJS/AppBackend/public/angular",
 

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM