Gulp `serve:before` tasks not running in Ionic CLI v 3 - ionic-framework

Gulp serve:before tasks are not running in the Ionic CLI v3. They used to run well in Ionic CLI 2 and Ionic CLI 1.
gulp.task('serve:before', ['watch']);
This is the task. My app uses Ionic 1 and I did the necessary configurations and it is running well on Ionic CLI 3 upon ionic serve but not the gulp task serve:before is not running.

I believe you can update your code from:
gulp.task('serve:before', ['watch'])
to
gulp.task('ionic:watch:before', ['watch'])
If you install the ionic gulp plugin here.
My task also had a 'default' task, which can just be included alongside the watch task as before, so mine currently looks like this:
gulp.task('ionic:watch:before', ['default', 'watch'])
The weird thing is that it does not show any of the code being compiled on startup as it used to, but it does seem to actually do this.
=======================================
Update for ionic CLI 4
I had to update the task name to the following in ionic cli 4:
gulp.task('ionic:serve:before', ['default', 'watch'])

Related

ionic info command exits without any error

I got a new laptop and I installed node, ionic and angular. I added ANDROID_SDK_HOME, ANDROID_HOME and JAVA_HOME in environment. ionic version is 6.20.2, node version is v16.17.1 and angular version is 14.2.4 and npm version is 8.15.0. When I use ionic serve, application opens in browser. But when I use ionic info, it exits without any error. Same happens when I try ionic cap build android.
I had a similar error when generating the build for Android, the command ended without any error message or warning.
After many tests it was only solved by downgrading.
npm install --global #ionic/cli#6.20.1

Electron run by Capacitor in Ionic 5: console logging and live reload not working

I've used Electron standalone before, and console.log() commands in main.js worked just fine (output to IDE console) and the electron-reload module also worked fine when content changes were detected in the Electron root folder.
I've now started a new Ionic 5 project, and added Electron to the project via Capacitor. Capacitor makes a few necessary changes to Electron (e.g. renaming main.js to index.js etc), I've now also have to start electron via capacitor npx cap open electron.
In doing so, console.log() commands in index.js are now NOT being output to the IDE console, errors are not being output to console, and the electron-reload module now serves a blank page when changes are detected… the only console output that I get is:
$ npx cap open electron
[info] Opening Electron project at ...
Is this a capacitor limitation or what configurations must be done to make this work ?
#ionic/cli#6.10.0
#capacitor/core#2.2.0
electron#8.3.1
also updated electron to latest 9.0.4 - same result.
here are steps to reproduce this:
# install ionic CLI
$ npm install -g #ionic/cli
# create project w/ capacitor
$ ionic start <project name> blank --type=angular --capacitor
# create initial build, needed by cap for electron
$ cd <ionic_project_folder>
$ ionic build
# add electron via cap
$ npx cap add electron
# run electron
$ npx cap open electron
if you enter console.log messages in electron’s index.js, none of them will be logged…
figured it out. Capacitor blocks all log messages by default, but you can run npm run electron:start from within the /electron folder and you'll get all log messages... HTH someone.

Ionic v1 use webpack instead of gulp

I have 2 questions:
Can I use webpack instead of gulp while running "ionic serve"
Can I use webpack instead of gulp while running "ionic build android" ?
Currently the configurations are under:
ionic.project file with the properties: "gulpStartupTasks" and "watchPatterns"
like a ionic team member said on the ionic forum: "it would require changing how the core of the CLI works".
So it's not recommended.
But what you can do is build your app with a dedicated npm webpack script, then run "ionic serve" to test your app in development mode.
About the android build, you can run it with the --no-build option, to skip the core gulp build tasks :
ionic cordova run android --no-build
I made a boilerplate available on github, if you wanna give a try.

Ionic CLI: [ERROR] Gulpfile (or dependent module) not found: .\gulpfile.js

Senario
I recently upon running an Ionic 3 app, updated (well accidentally) the Ionic CLI version. Now upon running the build from command line, it produces the following error every time and halts the build:
In the error message it says to disable the gulp integration by running the command ionic config set gulp.enabled false which I did. But still getting the same error. I also tried to add the command to the start script of package.json to no avail (not needed though since it seems the config is set globally).
Any help would be appreciated.
Ionic CLI version: 3.9.2
Finally figured out what the problem was. Even if Gulp integration has been disabled with the command ionic config set gulp.enabled false, as long as Gulp is a Dev dependency (i.e. there is a reference to it in the package.json under devDependencies) the Ionic CLI would (well, logically) assume that the Ionic project has a dependency on Gulp, therefore would throw the error (see original post).
Solution
The solution for a case where you don't want Gulp integration, apart from disabling it by running the command ionic config set gulp.enabled false, is to also make sure Gulp is NOT under the devDependencies in the package.json file.
Hope this helps anyone else with a similar issue.
NOTE: Not sure from which version onwards Ionic requires integration with Cordova and Gulp in the shape of ionic.config.json file. Anyway, the above solution will be relevant for a similar case in any of those versions.

How to make a prod build in "Ionic upload" command?

I want to use Ionic deploy service in Ionic cloud.
When I run ionic upload command, a dev build is immediately triggered instead of prod build.
Is it possible to create a --prod build and upload?
One of major reasons is that multiple configurations in my code are bundled with --prod build only.
ionic upload --deploy=dev
[INFO] Running app-scripts build:
[09:55:59] build dev started ...
[09:55:59] clean started ...
[09:55:59] clean finished in 1 ms
You could pipe the npm scripts to run the ionic --prod first and then ionic upload
"scripts":{
"custom-upload":"ionic cordova build --prod | ionic upload"
}
and then run in the terminal
$: npm custom-upload
This will still run the dev build i think but your prod build should be packaged as well. It does not look like you can specify a build type in the ionic upload command, which makes me think that the ionic upload does not upload the production build to ionic view. And if that is that case then you might want to consider changing the configurations setup in a prod build to be set to only be used if not on localhost instead on based on the build.