如何在每次 ng 服务构建后链接 npm 脚本调用?
How to chain npm script call after each ng serve build?
我试图在 运行ning 时链接 ng serve
脚本调用,但是当我 运行 这个命令时,第二个链接脚本 build-components.js
运行仅在第一次调用时。
我认为 concurrently package here 将允许两个脚本根据文档 https://www.npmjs.com/package/concurrently
按顺序 运行
我打算做的是 运行 build-components.js
脚本每次 ng serve
运行s(即检测源更改)。
Package.json 脚本:
"build:watch": "concurrently \"ng serve --port 4003\" \"node build-components.js\""
测试
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 serve build 之后 运行 另一个 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
脚本供参考。它将一些额外的构建文件复制到 public 文件夹以供托管:
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
命令对此没有钩子。
只需在脚本中使用“post”
{
"scripts": [
"build": "ng build --watch',
"postbuild": "node build-components.js"
]
}
我试图在 运行ning 时链接 ng serve
脚本调用,但是当我 运行 这个命令时,第二个链接脚本 build-components.js
运行仅在第一次调用时。
我认为 concurrently package here 将允许两个脚本根据文档 https://www.npmjs.com/package/concurrently
我打算做的是 运行 build-components.js
脚本每次 ng serve
运行s(即检测源更改)。
Package.json 脚本:
"build:watch": "concurrently \"ng serve --port 4003\" \"node build-components.js\""
测试
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 serve build 之后 运行 另一个 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
脚本供参考。它将一些额外的构建文件复制到 public 文件夹以供托管:
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
命令对此没有钩子。
只需在脚本中使用“post”
{
"scripts": [
"build": "ng build --watch',
"postbuild": "node build-components.js"
]
}