@dot-building/serve-and-run-angular (英语)
服务您的角工程, 然后运行一个命令 .
为什么?
您想要在应用程序准备好后运行命令或测试套件 。 应用需要一些时间来准备. Angular CLI有内置功能来简化目标的执行.
通常,您会启动您的服务器,并在 CI 环境中运行 a11y 或 e2e 假想.
这个构建器允许您在服务后运行任何命令,所以您不需要针对您想要使用的每一个工具的新模块.
使用量
将模块安装为 dev 依赖 :
npm i -D @dot-build/serve-and-run-angular
那就加进你的 angular.json 作为一个建筑.
例如运行 npm run e2e_ci 开发服务器准备好后 :
// e2e setup in angular.json
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"your-application": {
"projectType": "application",
"root": "",
"sourceRoot": "src",
"prefix": "app",
"architect": {
"serve": {
"builder": "@angular-devkit/build-angular:dev-server",
"options": {
"browserTarget": "your-application:build"
}
},
"e2e": {
"builder": "@dot-build/serve-and-run-angular:run",
"options": {
"devServerTarget": "your-application:serve",
"command": "npm",
"args": ["run", "e2e_ci"]
}
},
"build": {
// ...
}
}
}
}
}
选项
从 angular.json,可以调整如下:
// the target to serve
"devServerTarget": "your-application:serve",
// name of a command to execute
"command": "npm",
// arguments passed to that command
"args": ["run", "e2e_ci"]
从命令行也可以使用 --watch 在文件更改后继续运行命令。 查看前一个示例, 如果您的角配置有目标 e2e 为了测试,你想 运行它们一遍又一遍,你可以做到:
ng run your-application:e2e --watch