Ionic cordova build browser --prod --release

Has anyone found documentation or CLI help on how to build for browser in production? There seem to be official commands only for iOS and Android, not for Browser as platform.

Is this the correct command to build for the browser platform in production (Ionic 3)?

ionic cordova build browser --prod --release

I also want to use some Cordova plugins in production for the browser platform…

The Cordova browser platform is not officially supported by Ionic, that’s why there are no documented commands. PWA or web apps officialy are build using ionic build and ionic build --prod.

But the command you posted should work just fine when you only use Cordova plugins that have proper, full fledged browser support.

1 Like

Thanks for quick reply Sujan, but I get below:

$ ionic build --prod
The build command has been renamed. To find out more, run:

ionic cordova build --help

Post your ionic info output please - I think you are not using a recent CLI.

$ ionic info

cli packages:

@ionic/cli-utils  : 1.6.0 (D:\vdrive\web\hpm4\hpm\node_modules\ionic\node_modules\@ionic\cli-utils)
ionic (Ionic CLI) : 3.6.0 (D:\vdrive\web\hpm4\hpm\node_modules\ionic)

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts              : 1.3.7
@ionic/cli-plugin-cordova       : 1.4.1
@ionic/cli-plugin-ionic-angular : 1.3.2
Cordova Platforms               : android 6.2.3 browser 4.1.0
Ionic Framework                 : ionic-angular 3.2.1

System:

Node : v6.11.1
OS   : Windows 10
npm  : 3.10.10

You should upgrade these. CLI is on 3.9.x now and app-scripts on 2.x (note the breaking changes in the changelog).

What is the recommended way to upgrade Ionic CLI? I see that many get problems when upgrading and even need to delete and reinstall Cordova, Ionic, npm and node… How do I avoid that?

You might not be able to. It depends how correctly you installed previous versions. If you haven’t installed nvm yet, I recommend you do that now, to manage your Node installation. It makes Ionic updates much simpler.

Run ionic info and do what it tells you to - it normally recognizes updates. Otherwise just run npm install -g ionic and then ionic info, it will trigger the following updates or removals…

I did that but still get:
cli packages:

@ionic/cli-utils  : 1.6.0 (D:\vdrive\web\hpm4\hpm\node_modules\ionic\node_modules\@ionic\cli-utils)
ionic (Ionic CLI) : 3.6.0 (D:\vdrive\web\hpm4\hpm\node_modules\ionic)

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts              : 1.3.7
@ionic/cli-plugin-cordova       : 1.4.1
@ionic/cli-plugin-ionic-angular : 1.3.2
Cordova Platforms               : android 6.2.3 browser 4.1.0
Ionic Framework                 : ionic-angular 3.2.1

System:

Node : v6.11.1
OS   : Windows 10
npm  : 3.10.10

Then the same command without the -g.

I tried
npm install -g ionic
npm install ionic
npm install -g ionic@latest
npm install -g cordova@latest
npm install ionic@latest
npm install cordova@latest

But nothing seems to help…

Still:
@ionic/cli-utils : 1.9.2
ionic (Ionic CLI) : 3.9.2

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts : 1.3.7
Cordova Platforms  : android 6.2.3 browser 4.1.0
Ionic Framework    : ionic-angular 3.2.1

Hi ionite.

I use the command:
NPM run ionic:build --prod

I am going for PWAs. Future is coming…

OK, but does NPM run ionic:build --prod include the Cordova plugins for your PWA?

Well that is the most current version right now! so it worked.

You should upgrade app-scripts as well, note the breaking changes in 2.x in the changelog though.

That command will do different things and not include Cordova (and is similar to ionic build --prod)

OK good. So how do I upgrade app-scripts the best way?

npm install @ionic/app-scripts, then do what the changelog says.

I did that now. How much of what the changelog say shall I really do? Like of below:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“win32”,“arch”:“x64”})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\watchpack\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“win32”,“arch”:“x64”})
npm WARN @ionic/app-scripts@1.3.7 requires a peer of @angular/core@* but none was installed.
npm WARN @ionic/app-scripts@1.3.7 requires a peer of @angular/compiler@* but none was installed.
npm WARN @ionic/app-scripts@1.3.7 requires a peer of @angular/compiler-cli@* but none was installed.
npm WARN @ionic/app-scripts@1.3.7 requires a peer of @angular/tsc-wrapped@* but none was installed.
npm WARN @ionic/app-scripts@1.3.7 requires a peer of rxjs@* but none was installed.
npm WARN @ionic/app-scripts@1.3.7 requires a peer of sw-toolbox@* but none was installed.
npm WARN @ionic/app-scripts@1.3.7 requires a peer of typescript@* but none was installed.
npm WARN @ionic/app-scripts@1.3.7 requires a peer of zone.js@* but none was installed.
npm WARN tslint@3.15.1 requires a peer of typescript@>=1.7.3 but none was installed.

On Ionic info I now get:
D:\vdrive\web\map\hpm>ionic info
[ERROR] Error with .\node_modules\ionic-angular\package.json file: FILE_NOT_FOUND

cli packages: (C:\Users\aaaaaaa\AppData\Roaming\npm\node_modules)

@ionic/cli-utils  : 1.9.2
ionic (Ionic CLI) : 3.9.2

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts : 1.3.7
Cordova Platforms  : none
Ionic Framework    : not installed

System:

Node : v6.11.1
npm  : 3.10.10
OS   : Windows 10

That is not the changelog, but the output of the install process.

The installation also didn’t work, see the identical app-scripts version in ionic info.
Also something else broke as it doesn’t recognize Ionic Framework vesion any more.

I think this is beyond saving.

One solution: Uninstall your node, install nvm (or nvm-windows when you are using Windows), install a new node with this, then install ionic and cordova again and try your command again. The problem should be gone.