@dot-build/serve-and-run-angular

中文文档
2.0.0发布于 2023/07/29MITTypeScriptCommonJS近 30 天下载 5069

Angular CLI builder to serve the application and run a command

原始使用文档
文档目录3 节
  1. Why?
  2. Usage
  3. Options

@dot-build/serve-and-run-angular

Serve your Angular project, then run a command.

Why?

You want to run a command or test suite after the app is ready. The app takes some time to be ready. The Angular CLI has built-in features to streamline the execution of targets.

Usually, you start your server and run a11y or e2e scenarios on a CI environment.

This builder allows you to run any command after serve, so you don't need a new module for each and every tool you want to use.

Usage

Install the module as a dev dependency:

npm i -D @dot-build/serve-and-run-angular

Then add it to your angular.json as a build.

For example, to run npm run e2e_ci after the development server is ready:

// 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": {
          // ...
        }
      }
    }
  }
}

Options

From angular.json, the following can be adjusted:

// 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"]

From a command-line you can also use the --watch option to continuouly run the command after files change. Looking at the previous example, if your angular configuration has a target e2e for your tests, and you want to run them over and over, you can do:

ng run your-application:e2e --watch

版本与发布记录

@dot-build/serve-and-run-angular 共发布 4 个版本,首次发布于 2021/08/16;过去 12 个月发布了 0 个版本。

版本发布日期距今
2.0.0latest2023/07/293 年前
1.0.22021/08/195 年前
1.0.12021/08/185 年前
1.0.02021/08/165 年前

关于 @dot-build/serve-and-run-angular 的常见问题

@dot-build/serve-and-run-angular 是什么?

Angular CLI builder to serve the application and run a command

如何安装 @dot-build/serve-and-run-angular?

在项目目录运行 npm install @dot-build/serve-and-run-angular,或使用 pnpm add / yarn add / bun add。

@dot-build/serve-and-run-angular 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dot-build/serve-and-run-angular 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

@dot-build/serve-and-run-angular 可以商用吗?

@dot-build/serve-and-run-angular 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dot-build/serve-and-run-angular 的下载量有多少?

根据 npm 官方下载统计,@dot-build/serve-and-run-angular 在 2026/10/13 – 2026/11/11 这 30 天内被下载 5,069 次,日均约 169 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dot-build/serve-and-run-angular 还在维护吗?

最新版本 2.0.0 发布于 2023/07/29(3 年前);至今共发布 4 个版本,其中过去 12 个月发布了 0 个;首次发布于 2021/08/16。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。