How To Ionic Cli Hook


I’m trying to create a simple ionic cli hook. Following the docs:

I’ve added the example to package.json:

  "scripts": {
    "clean": "ionic-app-scripts clean",
    "build": "ionic-app-scripts build",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "custom-build-environment.js",
    "ionic:serve:before": "cp somefile www/somefile"

Nothing happens. At the least, would have expected an error. Removing the entire scripts xml block doesn’t seem to do anything either. I can still do ionic serve, ionic build, etc.

cli packages: (C:\Users\matth\AppData\Roaming\npm\node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0

global packages:
cordova (Cordova CLI) : 8.0.0

local packages:
@ionic/app-scripts : 3.1.9
Cordova Platforms : android 6.4.0 ios 4.5.4 windows 4.4.2
Ionic Framework : ionic-angular 3.9.2

Android SDK Tools : 26.1.1
Node : v8.9.4
npm : 5.6.0
OS : Windows 10

Environment Variables:
ANDROID_HOME : C:\Users\matth\AppData\Local\Android\Sdk

backend : pro



Resolved. I incorrectly assumed I could: use ionic:serve:before

Changing package.json to use:
“ionic:watch:before”: “cp somefile www/somefile”

Ran successfully.

$ ionic serve
> npm run ionic:watch:before

> mobile@0.0.1 ionic:watch:before P:\wwwroot\MWC_app\mobile
> cp somefile www/somefile

cp: cannot stat 'somefile': No such file or directory