Note: for support questions, please use one of these channels:
https://forum.ionicframework.com/
http://ionicworldwide.herokuapp.com/
After upgrading to app-script 1.0.0 ionic v2 final, prod flag is not producing the "prod" build with "ionic build android --prod"
current output on terminal ;
command executed : ionic build android --prod
Actual :
ionic-app-scripts build
[01:40:53] ionic-app-scripts 1.0.0
[01:40:54] build dev started ...
[01:40:54] clean started ...
[01:40:54] clean finished in 3 ms
[01:40:54] copy started ...
[01:40:54] transpile started ...
[01:40:58] transpile finished in 4.61 s
[01:40:58] webpack started ...
[01:40:58] copy finished in 4.92 s
[01:41:10] webpack finished in 11.67 s
[01:41:10] sass started ...
[01:41:12] sass finished in 1.76 s
[01:41:12] build dev finished in 18.07 s
Expected:
ionic-app-scripts build
[01:40:53] ionic-app-scripts 1.0.0
[01:40:54] build prod started ...
[01:40:54] clean started ...
[01:40:54] clean finished in 3 ms
[01:40:54] copy started ...
[01:40:54] transpile started ...
[01:40:58] transpile finished in 4.61 s
[01:40:58] webpack started ...
[01:40:58] copy finished in 4.92 s
[01:41:10] webpack finished in 11.67 s
[01:41:10] sass started ...
[01:41:12] sass finished in 1.76 s
[01:41:12] build prod finished in 18.07 s
Steps to reproduce:
1.
2.
3.
main.ts file :
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
import {enableProdMode} from '@angular/core';
enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
tried also :
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
//import {enableProdMode} from '@angular/core';
//enableProdMode();
platformBrowserDynamic().bootstrapModule(AppModule);
Which @ionic/app-scripts version are you using?
ionic info :
Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0
Ionic CLI Version: 2.1.8
Ionic App Lib Version: 2.1.4
Ionic App Scripts Version: 1.0.0
ios-deploy version: Not installed
ios-sim version: Not installed
OS: OS X El Capitan
Node Version: v6.7.0
Xcode version: Xcode 8.2.1
Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)
Try it with npm run ionic:build --prod. That should do the prod build
My guess is you need to update to the latest Ionic CLI.
npm uninstall -g ionic
npm install -g ionic@latest
Sudo may or may not be required depending on your set-up.
Then ionic run android --prod should work. Please let me know if this does not resolve the issue and I will re-open.
Thanks,
Dan
HI Dan,
I tried as you suggested :
so as from my package.json structure :
it worked with , npm run build --prod instead. Am I missing any configuration? since even after doing uninstall and reinstalling of ionic@latest did not resolve this.
ionic run android --prod still not working.
package.json
{
"name": "Cuppa",
"author": "Chitrang Natu",
"homepage": "http://cuppa.com/",
"private": true,
"scripts": {
"build": "ionic-app-scripts build",
"watch": "ionic-app-scripts watch",
"serve:before": "watch",
"emulate:before": "build",
"deploy:before": "build",
"build:before": "build",
"run:before": "build"
},
"dependencies": {
"@angular/common": "2.2.1",
"@angular/compiler": "2.2.1",
"@angular/compiler-cli": "2.2.1",
"@angular/core": "2.2.1",
"@angular/forms": "2.2.1",
"@angular/http": "2.2.1",
"@angular/platform-browser": "2.2.1",
"@angular/platform-browser-dynamic": "2.2.1",
"@angular/platform-server": "2.2.1",
"@ionic/storage": "1.1.7",
"@types/lodash": "4.14.43",
"angular2-moment": "^1.0.0",
"angularfire2": "^2.0.0-beta.7.1-pre",
"chart.js": "2.3.0",
"es6-shim": "0.35.0",
"ionic": "^2.2.1",
"ionic-angular": "2.0.0",
"ionic-native": "2.2.11",
"ionic2-rating": "0.0.10",
"ionicons": "3.0.0",
"reflect-metadata": "^0.1.8",
"rxjs": "^5.0.0-beta.12",
"sw-toolbox": "3.4.0",
"systemjs": "0.19.39",
"typings": "^1.4.0",
"whatwg-fetch": "^2.0.1",
"zone.js": "^0.6.21"
},
"devDependencies": {
"@ionic/app-scripts": "1.0.0",
"@types/request": "0.0.30",
"typescript": "^2.0.3"
},
"cordovaPlugins": [
"cordova-plugin-device",
"cordova-plugin-console",
"cordova-plugin-camera",
"cordova-plugin-compat",
"cordova-plugin-crop",
"cordova-plugin-file",
"cordova-sms-plugin",
"cordova-plugin-whitelist",
"cordova-plugin-splashscreen",
"cordova-plugin-statusbar",
"ionic-plugin-keyboard",
{
"variables": {
"SENDER_ID": "XXXXXXXXXX"
},
"locator": "phonegap-plugin-push",
"id": "phonegap-plugin-push"
}
],
"cordovaPlatforms": [
"ios",
{
"platform": "ios",
"version": "",
"locator": "ios"
},
{
"platform": "android",
"version": "",
"locator": "android"
}
],
"description": "Cuppa : A business coffee APP"
}
Your package.json scripts section should look like this:
https://github.com/driftyco/ionic2-app-base/blob/master/package.json#L6-L11
@danbucholtz thank you the command worked!
But now I am getting this error :
Uncaught Error: Cannot find module "./app.module.ngfactory"
main.ts file :
import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
import { AppModule } from './app.module';
platformBrowserDynamic().bootstrapModule(AppModule);
Please advice.
I removed node_modules and did npm install then all worked! Thank you for this amazing framework and your support.
@danbucholtz I'm having the same issue, upgrading to the latest version of ionic did not work. However, npm run ionic:build android --prod --release is working. But I can't find the .apk in the android/build/outputs folder.
[10:32:03] ionic-app-scripts 1.1.4
[10:32:03] build prod started ...
[10:32:03] clean started ...
[10:32:03] clean finished in 2 ms
[10:32:03] copy started ...
[10:32:03] ngc started ...
[10:32:13] ngc finished in 9.62 s
[10:32:13] preprocess started ...
[10:32:13] optimization started ...
[10:32:13] copy finished in 9.86 s
[10:32:24] optimization finished in 11.08 s
[10:32:24] preprocess finished in 11.08 s
[10:32:24] webpack started ...
[10:32:44] webpack finished in 20.18 s
[10:32:44] sass started ...
[10:32:44] transpile bundle started ...
[10:32:56] transpile bundle finished in 11.47 s
[10:32:56] uglifyjs started ...
[10:32:57] sass finished in 12.26 s
[10:32:57] cleancss started ...
[10:32:58] cleancss finished in 990 ms
[10:33:15] uglifyjs finished in 18.76 s
[10:33:15] postprocess started ...
[10:33:15] postprocess finished in 2 ms
[10:33:15] lint started ...
[10:33:15] build prod finished in 71.18 s
The issue of --prod not working even when typed into the command exists also on Ionic Package, don't know if related.
@kamok,
Sorry, I'm not sure what's going on. The @ionic/app-scripts build is working correctly. Can you provide some more info? I would think the APK would be there. Can you try updating cordova perhaps?
Thanks,
Dan
@danbucholtz I fixed it. It was a bug in ionic-cli that just required me to update ionic. npm update ionic didn't work, so I ended up removing npm and got a new npm via Homebrew. Works now.
The problem is with the "page-name.component.ts" file that is created when you use the "ionic generate page" command.
Create your pages manually and run it (ionic run android --prod) or (ionic run android --prod) again.
it worked for me.
Home they fix it soon.
Most helpful comment
Try it with
npm run ionic:build --prod. That should do the prod buildMy guess is you need to update to the latest Ionic CLI.
Sudo may or may not be required depending on your set-up.
Then
ionic run android --prodshould work. Please let me know if this does not resolve the issue and I will re-open.Thanks,
Dan