I am working on a project to create a mobile application version of a website(website already deployed and serving), we are using Ionic v1.7.16.
It has been reviewed by my superiors whether if we can work on Ionic project and then deploy it to the web also(replacing the previous web version), to have nearly same interface and user experience in both mobile and browser(desktop).
I've read about "Ionic Browser Platform", experienced with it a bit and I haven't come across with a problem.
My questions is same as the title. Is there a difference between "ionic serve" and "ionic build browser"?
My observations:
Ionic browser platform is still in beta, and I haven't encountered with too many sources like I do about Ionic platform android. FAQ/sources about Ionic browser platform of all kind is also appreciated.
What's the difference between “ionic build” and “ionic prepare”? ionic prepare <platform> copies all files from the www folder into the target platform's www folder. ionic build <platform> also does this, but also builds the app's source code so that it can be run on a simulator/emulator or a device.
ionic build uses the Angular CLI. Use ng build --help to list all Angular CLI options for building your app. See the ng build docs for explanations.
I am working with my first Ionic2 RC1 App having 2 platforms added (Android and Browser) and I appreciate differences between this commands...
It generates (in my case) this outputs:
$ ionic serve browser
myproject_root
|-- www (13 MB)
|-- assets (1.40 MB)
|-- build (11.5 MB)
|-- main.css (729.90 KB)
|-- main.js (3.50 MB)
|-- main.js.map (7.10 MB)
|-- polyfills.js (84.10 KB)
|-- index.html (1.20 KB)
|-- manifest.json (313 B)
|-- service-worker.js (3.60 KB)
$ ionic build browser
myproject_root
|-- www (5.60 MB)
|-- assets (1.40 MB)
|-- build (4.20 MB)
|-- main.css (636.70 KB)
|-- main.js (1.60 MB)
|-- main.js.map (1.90 MB)
|-- polyfills.js (84.10 KB)
|-- index.html (1.20 KB)
|-- manifest.json (313 B)
|-- service-worker.js (3.60 KB)
Additionally, I find this other deployable output:
myproject_root
|-- platforms
|-- browser
|-- www (5.70 MB)
|-- assets (1.40 MB)
|-- build (4.20 MB)
|-- main.css (636.70 KB)
|-- main.js (1.50 MB)
|-- main.js.map (1.80 MB)
|-- polyfills.js (84.10 KB)
|-- cordova-js-src (9.40 KB)
|-- confighelper.js (3.00 KB)
|-- exec.js (4.70 KB)
|-- platform.js (1.60 KB)
|-- plugins (17.60 KB)
|-- cordova-plugin-device (5.70 KB)
|-- cordova-plugin-splashscreen (6.00 KB)
|-- cordova-plugin-statusbar (5.10 KB)
|-- ionic-plugin-keyboard (643 B)
|-- config.xml (1.40 KB)
|-- confighelper.js (3.00 KB)
|-- cordova_plugins.js (2.00 KB)
|-- cordova.js (59.00 KB)
|-- exec.js (4.70 KB)
|-- platform.js (1.60 KB)
|-- index.html (1.30 KB)
|-- manifest.json (313 B)
|-- service-worker.js (3.60 KB)
I can deploy all this 3 folders in my web server with different load times.
Here is a resume of my tests with deactivated caches
ionic serve's ./www output
ionic build's ./www output
ionic build's ./platforms/browser/www output
Only for reference: The Android .apk weights 3.70 MB
DISCLAIMER: I have recently read that Ionic Team is thinking about change rollup for webpack so all this could change in future Ionic 2 versions.
One of the Ionic developers said their production for browser build is still a work in progress. You can see Harrington's comments here:
https://github.com/ionic-team/ionic/issues/10635
He recommends using npm run build --prod
for now.
I would recommend also minifying, compressing, and adding version number to the .js files and other includes, to force the browser refresh.
I notice that Angular 2/4 is further along in their production build process. I wonder if ng build --prod
is where the Ionic team is trying to go, and if you can use that to build the ionic project as well somehow.
Angular has a benefit of changing includes on index.html to have random numbers on the end, forcing user browsers to refresh files like main.js
which is critical.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With