我正在尝试在运行时链接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');
})();
ng serve
在监视模式下运行时未完成,因此链接要在其后运行的项目将无效。 serve
命令对此没有钩子。"build:watch": "ng serve --port 4003" && "node build-components.js"
让我知道您是否还有问题