Production mode errors in browser

Hi,

I’m trying to test my app in production mode in my browser. The app is meant to run on iPad but I just want to make sure some variables are set up properly in production mode.

My package.json looks like so:

  "scripts": {
    "start": "ionic serve",
    "docs": ".\\node_modules\\.bin\\typedoc --out ./docs/ ./src/",
    "clean": "ionic-app-scripts clean",
    "build": "rimraf www && ionic-app-scripts build --aot --prod",
    "lint": "ionic-app-scripts lint",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  }

When I run the npm run build command, a www folder is created in the root of my project. When I open the index.html file in that folder, a few errors appear:

image

It looks like it can’t find a cordova.js file and it also looks like it can’t properly enable prod mode.
My [DEVELOPMENT MODE] line is called in a random config file I use:

import { isDevMode } from '@angular/core';

let apiConfig = {
   apiUrl: '',
   logAuthorizationToken: ''
};
if (isDevMode()) {
   console.log('[DEVELOPMENT MODE]');
   apiConfig = {
       apiUrl: 'https://xxxxxxxx/xxx',
       logAuthorizationToken: 'xxxxxxx'
   };
} else {
   console.log('[PRODUCTION MODE]');
   apiConfig = {
       apiUrl: 'https://xxxxxxxx/xxx',
       logAuthorizationToken: 'xxxxxxx'
   };
}

I must be missing something obvious, but I can’t really tell what.
Thank you for your help!

You normally don’t have to change anything in package.json but can just run ionic build --prod to get a plain web app.

The issue remains when resetting the package.json file and using the ionic build --prod command.

There is some logic in the build that messes with dev/production mode of Android. You might look into if this applies to your file as well.

Hah! You are correct, it works fine when removing that line.

What would then be the best way to check whether or not the app is running in production?

Sorry, no idea. Can’t help here.

Hi,

To test a ‘browser’ --prod build I:

npm run clean
npm run build --prod

Then:

cd www
python -m SimpleHTTPServer 8080

And, navigate to:

http://localhost:8080

See: https://github.com/Robinyo/big-top

Cheers
Rob