每个ng服务更改后如何链接npm脚本调用?

问题描述 投票:0回答:1

我正在尝试在运行时链接ng serve脚本调用,但是当我运行此命令时,第二个链接的脚本build-components.js仅在第一次调用时运行。我认为这里的[[concurrently包将允许两个脚本根据docs https://www.npmjs.com/package/concurrently

顺序运行我的目标是运行build-components.jsng serve每次运行时编写脚本,即检测源更改。

Package.json密码

"build:watch": "concurrently \"ng serve --port 4003\" \"node build-components.js\""

Testing

concurrently "ng serve --port 4003" "node build-components.js" [1] node build-components.js exited with code 0 [0] i 「wds」: Project is running at http://localhost:4003/webpack-dev-server/

问题:

每次更改ng服务后如何运行另一个npm脚本?

我也看过npm post钩子,但这似乎在ng serve运行后也没有运行脚本。http://www.marcusoft.net/2015/08/pre-and-post-hooks-for-npm-scripting.html#hooks-pre-and-post

这是build-components.js脚本供参考。它将一些额外的构建文件复制到公共文件夹中进行托管:

const fs = require('fs-extra'); const concat = require('concat'); (async function build() { const js = [ './dist/app/runtime-es2015.js', './dist/app/main-es2015.js', './dist/app/scripts.js', ]; const css = ['./dist/app/styles.css']; await fs.ensureDir('components'); await concat(js, 'components/component.js'); await concat(css, 'components/component.css'); })();

javascript angular typescript npm-scripts concurrently
1个回答
0
投票
不确定,但是您可以尝试此操作

"build:watch": "ng serve --port 4003" && "node build-components.js"

让我知道您是否还有问题
© www.soinside.com 2019 - 2024. All rights reserved.