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

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

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

顺序运行我的目标是每次build-components.js运行(即检测到源更改)都运行ng 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
2个回答
1
投票
这是不可能的。 ng serve在监视模式下运行时未完成,因此链接要在其后运行的项目将无效。 serve命令对此没有钩子。

0
投票
不确定,但是您可以尝试此操作

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

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