Ionic-cli: npm script hooks not called anymore

Created on 20 Apr 2017  路  11Comments  路  Source: ionic-team/ionic-cli

What version of the CLI are you using? Output of ionic --version

3.0.0-beta7

Short description of the problem:

npm script hooks don't work anymore.
In ionic-cli 2.x (at least) the following hooks were available:

serve:before
build:before
emulate:before
run:before

The problem might be related to the following issue: https://github.com/driftyco/ionic-cli/issues/1989

What behavior are you expecting?

I am expecting the hooks to be called or any equivalent replacement as support for preprocessing steps is a crucial feature.

Post the output of ionic info below please

Your system information:

Cordova CLI: 6.5.0 
Ionic CLI Version: 3.0.0-beta7
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Linux 4.10
Node Version: v6.5.0
Xcode version: Not installed

Most helpful comment

This is working in master 馃槃 You can test this if you want: npm i -g ionic@canary

Docs are here: https://github.com/ionic-team/ionic-cli#cli-hooks

Thanks for the issue report!

All 11 comments

@GerritErpenstein We will address this in a later release. I can tell you that a suitable replacement is coming.

This is working in master 馃槃 You can test this if you want: npm i -g ionic@canary

Docs are here: https://github.com/ionic-team/ionic-cli#cli-hooks

Thanks for the issue report!

@dwieeb F*ing awesome, great work and thank you very much! 馃槃馃憤
Unfortunately I don't have access to a dev machine the next 2 weeks to try the new feature.

No problem--the feature was pretty simple to implement 馃槃 And if there are issues, I'll be quick to fix them 馃挭

@dwieeb thank you for the hooks :) Is it possible to also pass parent process arguments to npm start script?

@sergkhl Passing process args might be a little hairy. If your npm script was something likenode something.js ; node something-else.js then the process args would only be appended to the second script. I'd rather use environment variables. Would you mind creating a new issue detailing the feature? Especially which process args you're looking for?

@dwieeb
Two users of ionic2-custom-icons (lib for adding custom icons) were successfully able to use the npm script hooks. 馃槃
One problem they found is the console output of the script isn't printed when the hook is called. (https://github.com/GerritErpenstein/ionic2-custom-icons/issues/18)
Sorry, I can't provide any example code as I'm still on a hiking trip but this should be reproducable pretty easily of it is really a bug.

@GerritErpenstein fixed in https://github.com/ionic-team/ionic-cli/commit/e838a5d78423514102aa06fe65af091d44fb87b3

I was hiding the output for some reason.

CLI v2 Had the ability to override the build hook.

This was needed due to the size of the app we were building. Below is the example we used to get past the running out of memory error.

"build": "node --max_old_space_size=4000 ./node_modules/.bin/ionic-app-scripts build --prod"

Since this is no longer a hook how would we handle something like this now?

@ztecharoberts node --max_old_space_size=4000 $(which ionic) cordova build --prod

No, I'm kidding. Let's talk. Can you create a new issue?

Was this page helpful?
0 / 5 - 0 ratings