Skip to content
This repository has been archived by the owner on Oct 12, 2023. It is now read-only.

npm scripts not triggered for ionic-cli 3.x #18

Closed
begriffin opened this issue Apr 19, 2017 · 18 comments
Closed

npm scripts not triggered for ionic-cli 3.x #18

begriffin opened this issue Apr 19, 2017 · 18 comments

Comments

@begriffin
Copy link

Just a quick note for updated ionic-app-scripts.
You need to change the scripts section in package.json to:

"ionic:build:before": "ionic2-custom-icons",
"ionic:serve:before": "ionic2-custom-icons",
@GerritErpenstein
Copy link
Owner

Hi @begriffin!
I'm a little bit confused. Where do these script keys come from?
After changing the script keys ionic2-custom-icons isn't triggered anymore.
I am using @ionic/app-scripts 1.3.4 and ionic-cli 2.2.2.

@begriffin
Copy link
Author

I have @ionic/app-scripts 1.3.1 and ionic-cli 3.0.0-beta7

I just took a guess at the keys after digging through things and not finding any reason why I was getting the error:
line: 1 File to import not found or unreadable: .tmp-custom-icons/scss/variables.scss Parent style sheet: stdin

When I changed to the ionic:build:before and ionic:serve:before everything worked great.

@GerritErpenstein
Copy link
Owner

Maybe there was a change in ionic-cli 3.x. I will check that tomorrow. Thank you very much for the report!

@GerritErpenstein
Copy link
Owner

After switching to ionic-cli 3.0.0-beta7 the scripts aren't triggered at all.
None of the following seem to work:

"build:before": "ionic2-custom-icons",
"serve:before": "ionic2-custom-icons",
"ionic:build:before": "ionic2-custom-icons",
"ionic:serve:before": "ionic2-custom-icons",

Actually any script is ignored, even ionic:build and ionic:serve.
This might be related to the following issue: ionic-team/ionic-cli#1989

But I don't understand why this works for you if you change the script names!?

I think I will have to spend some time to investigate this...

@GerritErpenstein GerritErpenstein changed the title Changes for using ionic-app-scripts ^1.3.1 npm scripts not triggered for ionic-cli 3.0.0-beta Apr 20, 2017
@GerritErpenstein
Copy link
Owner

As I couldn't find any code that implements this feature in ionic-cli 3.x I have opened an issue: ionic-team/ionic-cli#2124
Let's hope the ionic team resolves this issue soon.

@ThorvaldAagaard
Copy link

I have upgraded to Ionic CLI 3.1.2 and the suddenly realised that this plugin no longer was building during build of my app.

But for others in the same situation there is a simple solution until the proper hook will be available.

Just execute:

npm run prebuild

Then you will manually have to remember if the icons have been updated :-)

@GerritErpenstein GerritErpenstein changed the title npm scripts not triggered for ionic-cli 3.0.0-beta npm scripts not triggered for ionic-cli 3.x May 30, 2017
@davyzhang
Copy link

davyzhang commented May 31, 2017

npm run ionic2-custom-icons

should do the trick

@ThorvaldAagaard
Copy link

ThorvaldAagaard commented May 31, 2017

Yes, you are right. I was assuming that you had updated package.json according to the istallation guide, så I had this in my file

"scripts": {
    "prebuild": "ionic2-custom-icons",

I also realised that running

npm run build 

would build all

@GerritErpenstein
Copy link
Owner

Good news! The Ionic team provides a solution very soon. :-) See the last messages in the corresponding issue thread: ionic-team/ionic-cli#1989 (comment)

@mwiley63
Copy link

It looks like the new CLI (3.4) now resolves this issue: https://github.com/ionic-team/ionic-cli/blob/master/CHANGELOG.md

Would an acceptable integration be "ionic:build:before": "ionic2-custom-icons" in the scripts section?

@Gemeapp
Copy link

Gemeapp commented Jun 12, 2017

It is working fine with

"ionic:build:before": "ionic2-custom-icons"

Is there a way to get output from the build?

Now the result looks like this

npm run ionic:build:before
✔ Running command - done!

@mwiley63
Copy link

If you are lazy like me you could add "ci-icons": "ionic2-custom-icons" to scripts in package.json and run with npm run ci-icons.

I use that as a sanity check before I start release builds :)

However since 3.4 supports gulp tasks, a better solution would be to hook the gulp task into the CLI events and then you could control the outputs and errors.

@GerritErpenstein
Copy link
Owner

Npm script hooks have been fixed in ionic-cli v3 (see ionic-team/ionic-cli#2124 (comment))
The docs are here: https://github.com/ionic-team/ionic-cli#cli-hooks
To enable these hooks for ionic2-custom-icons just use ionic:watch:before and ionic:build:before (instead of serve:before and build:before). Make sure you have the latest version of ionic-cli.

Sounds like @Gemeapp got it working! 😄 Are you sure you are using the latest version of ionic-cli and the script call does not generate any console output? If this is the case, I will file another issue report.
Nevertheless this is good news! As an interim solution, I could make the npm script pipe the console output into a log file.

Unfortunately I'm on a hiking trip right now and don't have access to a dev machine to test it and make changes except updating the docs.

@GerritErpenstein
Copy link
Owner

@begriffin @ThorvaldAagaard @davyzhang @mwiley63
Can anyone of you confirm @Gemeapp 's findings that there is no console output?

@ThorvaldAagaard
Copy link

Alias Gemeapp :-)

This is ionic info

global packages:

@ionic/cli-utils : 1.4.0
Cordova CLI      : 7.0.1
Ionic CLI        : 3.4.0

local packages:

@ionic/app-scripts              : 1.3.7
@ionic/cli-plugin-cordova       : 1.4.0
@ionic/cli-plugin-ionic-angular : 1.3.1
Cordova Platforms               : android 6.2.3 ios 4.4.0
Ionic Framework                 : ionic-angular 2.2.0

System:

Node       : v6.9.5
OS         : Windows 10
Xcode      : not installed
ios-deploy : not installed
ios-sim    : not installed
npm        : 3.10.9

And there is no output from the

"ionic:build:before": "ionic2-custom-icons",

@GerritErpenstein
Copy link
Owner

@ThorvaldAagaard Thanks! I have reported the issue to the Ionic team. ionic-team/ionic-cli#2124 (comment)

@GerritErpenstein
Copy link
Owner

Using the latest alpha release of ionic-cli, the issue seems to be resolved. Install it (at your own risk) with the following command:

npm install -g ionic@3.4.0-alpha.e838a5d7

Don't forget to update when a new stable release becomes available!

@GerritErpenstein
Copy link
Owner

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants