ionic-team / ionic-app-scripts

App Build Scripts for Ionic Projects
http://ionicframework.com/
MIT License
608 stars 302 forks source link

Ionic 2 --prod flag and plugins issue #631

Closed daniele-sartiano closed 7 years ago

daniele-sartiano commented 7 years ago

Note: for support questions, please use one of these channels:

https://forum.ionicframework.com/ http://ionicworldwide.herokuapp.com/

Short description of the problem:

When I use the --prod flag, the building system don't add the cordova plugins. I have not error during the compilation of the apk.

What behavior are you expecting?

I'm expecting to use the cordova plugin also in prod mode.

Steps to reproduce:

  1. ionic build android

drDrin_algos@ ionic:build C:\projects\biocare\alfa\IonicNearU ionic-app-scripts build --prod

[15:37:09] ionic-app-scripts 1.0.0 [15:37:09] build prod started ... [15:37:09] clean started ... [15:37:09] clean finished in 8 ms [15:37:09] copy started ... [15:37:09] ngc started ... [15:37:33] ngc finished in 24.43 s [15:37:33] webpack started ... [15:37:34] copy finished in 25.04 s [15:37:43] webpack finished in 9.55 s [15:37:43] uglifyjs started ... [15:37:43] sass started ... [15:37:46] sass finished in 2.91 s [15:37:46] cleancss started ... [15:37:49] cleancss finished in 3.60 s [15:37:58] uglifyjs finished in 15.29 s [15:37:58] build prod finished in 49.37 s Running command: "C:\Program Files\nodejs\node.exe" C:\projects\biocare\alfa\IonicNearU\hooks\after_prepare\010_add_plat form_class.js C:\projects\biocare\alfa\IonicNearU ....

My package.json is:

{
  "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.6",
    "font-awesome": "^4.6.3",
    "ionic-angular": "^2.0.0-rc.4",
    "ionic-native": "2.2.12",
    "ionicons": "3.0.0",
    "moment": "2.15.1",
    "rxjs": "5.0.0-beta.12",
    "zone.js": "0.6.26"
  },
  "devDependencies": {
    "@ionic/app-scripts": "^1.0.0",
    "sw-toolbox": "^3.4.0",
    "typescript": "2.0.9"
  },
  "name": "drDrin_algos",
  "description": "drDrin algos",
  "scripts": {
    "ionic:build": "ionic-app-scripts build --dev",
    "ionic:serve": "ionic-app-scripts serve"
  },
  "cordovaPlugins": [
    "cordova-plugin-device",
    "cordova-plugin-console",
    "cordova-plugin-whitelist",
    "cordova-plugin-splashscreen",
    "cordova-plugin-statusbar",
    "ionic-plugin-keyboard",
    "cordova-sqlite-storage",
    "cordova-plugin-inappbrowser",
    "cordova-plugin-network-information",
    "de.appplant.cordova.plugin.local-notification",
    "phonegap-plugin-push"
  ],
  "cordovaPlatforms": [],
  "config": {
    "ionic_copy": "./copy.config.js",
    "ionic_source_map_type": "eval"
  }
}

Which @ionic/app-scripts version are you using? $ ionic info

Your system information:

ordova CLI: 6.4.0 Ionic Framework Version: 2.0.0-rc.4 Ionic CLI Version: 2.1.13 Ionic App Lib Version: 2.1.7 Ionic App Scripts Version: 1.0.0 ios-deploy version: Not installed ios-sim version: Not installed OS: Windows 10 Node Version: v5.0.0 Xcode version: Not installed

Other information: (e.g. stacktraces, related issues, suggestions how to fix, stackoverflow links, forum links, etc)

I reproduced the issue on Windows and Ubuntu. Without the --prod flag I have not problems with the plugins.

ataraxus commented 7 years ago

how does your tsconfig.json looks like? did you do a ionic state reset, if not try this if it fixes your error? also paste the exact error from the console.

daniele-sartiano commented 7 years ago

Here my tsconfig.json:

{
  "compilerOptions": {
    "allowSyntheticDefaultImports": true,
    "declaration": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [
      "dom",
      "es2015"
    ],
    "module": "es2015",
    "moduleResolution": "node",
    "sourceMap": true,
    "target": "es5"
  },
  "include": [
    "src/**/*.ts"
  ],
  "exclude": [
    "node_modules"
  ],
  "compileOnSave": false,
  "atom": {
    "rewriteTsconfig": false
  }
}

Yeah, with ionic state reset I had the same issue. In the following image you can see that LocalNotifications plugin and Push plugin are not installed on the device: ionic_error

And here the output of the compilation: error.txt

yasar-salim commented 7 years ago

please provide error showing on terminal

daniele-sartiano commented 7 years ago

@yasar-salim in my previous comment there is the file error.txt with the log of the terminal. Can you see it?

daniele-sartiano commented 7 years ago

Fixed. The problem was that I was using the plugins in the constructor of my providers, before the event "platform.ready", so the solution is to use the plugins after the platform.ready event.

quedicesebas commented 7 years ago

@daniele-sartiano what?