I am switching my Ionic 3 application to use Capacitor. Is the a way to build the application for production using, as we did before, something like --prod?
Short answer:
In your case, run ionic build --prod, then npx cap copy and finally build the app for production in the native IDE.
Detailed answer:
This is how the Capacitor app development workflow works:
Build the web application
Run npx cap copy
Build the app in the native IDE
Building the web application happens completely separated from Capacitor. You could use any framework in the development process. What only matters is that the builded application is located in the www folder. Using Ionic, you can perform a production build by running ionic build --prod.
Afterwards, Capacitor comes to place and copies the web application in the native IDE projects, where you can perform an app build. Some platform-specific extra settings / steps are required to make the app production ready, but this again doesn't have to do with Capacitor.
Just an update:
In Ionic 4:
To do production build try this below command:
npx ng build --aot=true --configuration="production"
and do
npx cap sync
Hope it helped.
Related
When I install for example the Insomnia plugin the Capacitor way like so:
npm install cordova-plugin-insomnia
npm install #ionic-native/insomnia
ionic cap sync
It still requires me to install the cordova plugin like this:
ionic cordova plugin add cordova-plugin-insomnia
In order to work. Otherwise it says: plugin_not_installed
My steps to make it work are:
Step 1: Add Insomnia to providers (#ionic-native/insomnia/ngx)
Step 2: Inject Insomnia within the constructor private insomnia: Insomnia
Am I forgetting something or do I just really need to ionic cordova plugin add for plugins that are not fully supported yet?
Probably obvious for most but just in case someone else might face this problem..
When you use capacitor you shouldn't start your server with ionic cordova run or ionic cordova build anymore.
Obviously you need to start it this way for livereload:
ionic cap run android -l --external
ionic cap run ios -l --external
That is because your application is using cordova and not capacitor..
Remove your platforms folder, and just to make sure and remove unnecessary cordova files which will increase your app size, remove cordova-android and cordova-ios from your package.json.. You do not need that for running your app based on capacitor.
Then, run this command.
ionic build
npx cap add android
npx cap add ios
For each successive build, in case you add or remove a plugin, use npx cap sync
Otherwise use npx cap copy
Reference Docs
I deployed my app in ionic-appflow. It created a Web Build, it was build using command ionic build and due to which its vendor.js size is 4mb.
I want to create a production build using command like
ionic build --prod or
ionic build --aot
How do we do that in ionic-appflow ? My main concern is vendor.js size.
in my old ionic version i was able to run and install ionic properly.
but while creating a new project in ionic i get this error
please help me out.
C:\>ionic start
Every great app needs a name!
Please enter the full name of your app. You can change this at any time. To bypass this prompt next time, supply name,
the first argument to ionic start.
? Project name: sumith
Let's pick the perfect starter template!
Starter templates are ready-to-go Ionic apps that come packed with everything you need to build your app. To bypass this
prompt next time, supply template, the second argument to ionic start.
? Starter template: blank
√ Preparing directory .\sumith - done!
√ Downloading and extracting blank starter - done!
Installing dependencies may take several minutes.
* IONIC DEVAPP *
Speed up development with the Ionic DevApp, our fast, on-device testing mobile app
> npm i
npm WARN deprecated circular-json#0.5.9: CircularJSON is in maintenance
only, flatted is its successor.
[ ..............] / fetchMetadata: sill resolveWithNewModule
punycode#2.1.1 checking installable status
set NODE_TLS_REJECT_UNAUTHORIZED=0 before running ionic start.
I am new to app development and have been using the ionic framework to build my app. I am ready to publish, and want to use ionic deploy, as it seems efficient.
My question is do I need to upload my app to Apple/play store before I can use Ionic deploy, or can I use ionic deploy when publishing for the first time?
You must first publish and release your app using the standard store process, here is a good guide to help with it.
Then you can use Ionic Deploy for subsequent deployments / releases.
On this website (https://ionicframework.com/docs/intro/deploying/) I read that I should give this command on the command prompt: ionic cordova run android --prod --release
I tried it but it only tried to start the app on an emulator (I have some problems with it, so it didn't actually start the emulator). Does this command also create a file I can put on my mobile and install the app? I don't want to put the app on Google play, just on my mobile.
I tried putting the android-debug.apk on my mobile and running it but my mobile couldn't install it (.../platforms/android/build/outputs/apk/android-debug.apk)
I'm not trying to test the app on my mobile, I'm trying to install it.
If you want to deploy the apk to your device
ionic cordova run android --device is indeed correct. (try adding --device)
You only need --prod --release when building for production (longer buildtime).
Before running (= building, installing and starting your app) check if your device has USB-debugging enabled. You can check if your device is connected by running adb devices. Since the run command includes building, yes run should create a apk for you.
As you said you also could install the apk manually. Here make sure to use the correct apk. android-debug.apk is the development build (no --release tag) and since your trying to run a production one (--release) you are looking for android-release.apk or android-release-unsigned.apk.
go to settings -> security in your phone then check Unknown sources (Allow installation of apps from sources other than the play store) and try to put the android-debug.apk again. this should work