本文介绍了ng build之后的angular-cli run命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道如何在完成后将ng build扩展为运行任务.

I am wondering how to extend ng build to run tasks after it has finished.

目前,我的最终目标是将"package.json"复制到dist文件夹中.

At the moment, my end goal is to copy my 'package.json' to the dist folder.

如果我使用纯npm,则类似这样:

Something like this if I was using plain npm:

"postbuild": "cpx ./package.json ./dist/",

我知道在angular-cli.json中,我可以使用资产"来复制静态文件,但不适用于src之外的文件.所以,我想知道是否可以在ng构建完成之后执行复制任务.

I know in the angular-cli.json I can use "assets" to copy static files, but it does not work for files outside of src. So, I'm wondering if I can do the copy task after ng build completes.

推荐答案

定义npm脚本

"build":" "ng build"

并添加postbuild脚本.

and add the postbuild script, too.

"postbuild": "cpx ./package.json ./dist/",

这样,在您运行npm run build之后,将调用复制脚本.

This way the copy script gets called after you run npm run build.

这篇关于ng build之后的angular-cli run命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 11:09
查看更多