如何在离子app-scripts构建期间自定义步骤?

Nor*_*mac 5 tslint ionic2

我想开始使用tslint 4,但离子app-scripts还不支持它:https://github.com/driftyco/ionic-app-scripts/issues/649

我已成功配置lint脚本(在package.json中)ng lint而不是ionic-app-scripts lint在运行时运行npm run lint:

  "scripts": {
    "build": "ionic-app-scripts build",
    "lint": "ng lint",
    ...
  }
Run Code Online (Sandbox Code Playgroud)

但是,此更改不会影响构建脚本.构建仍然运行ionic-app-scripts lint而不是ng lint.

是否可以配置在构建脚本中运行哪些命令?

Mat*_*tir 0

事件这个问题已经很老了,这里是一个尝试,我总是使用它,因为它在不同的项目中对我有用:

脚本链接

在您的情况下,您可以将 lint 添加到构建中,也可以创建一个新脚本来执行这两个操作。

将 lint 添加到构建中:

"scripts": {
    "build": "ng lint && ionic-app-scripts build",
    "lint": "ng lint",
}
Run Code Online (Sandbox Code Playgroud)

创建一个新的:

"scripts": {
    "build": "ionic-app-scripts build",
    "lint": "ng lint",
    "linted-build": "npm run lint && npm run build"
}
Run Code Online (Sandbox Code Playgroud)

确保您使用&&不执行下一个脚本。--> 因此,如果 linting 失败,则不会执行构建。如果您想继续,可以使用单个&. 希望这些信息对您有帮助;)