ionic-team / ionic-team/ionic-cli
ionic build --prod fails for firebase(even with blank app)
- Dominant language
- TypeScript
- Stars
- 2k
- Forks
- 682
- PR merge metrics
- No merged PRs in 30d
Description
**Description:**
After adding firebase(not angularfire2) **ionic build --prod** hangs after _copy finished_ step
The same work perfectly without --prod option. I'm using firebase auth, database and messaging in by PWA + Mobile Apps. All the features works perfectly in non-prod mode.
I even tried setting --max-old-space-size to 4GB but it still doesn't work.
**Steps to Reproduce:**
I have tried the same for blank ionic app.
1. Create new blank ionic app
`ionic start blank1 blank`
2. Need to add platform as ionic build needs atleast one platform
`ionic cordova add platform android`
3. build without --prod will be successful
`ionic build`
4. build with --prod will also be successful
`ionic build --prod`
5. Now add firebase
`npm i -s firebase`
6. add firebase imports
As mentioned at https://www.npmjs.com/package/firebase#include-only-the-features-you-need
I have used the below code to import firebase app, auth database and messaging:
````
// This import loads the firebase namespace along with all its type information.
import firebase from 'firebase/app';
// These imports load individual services into the firebase namespace.
import 'firebase/auth';
import 'firebase/database';
import 'firebase/messaging';
````
I've added these imports in home.ts as:
````
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
// This import loads the firebase namespace along with all its type information.
import firebase from 'firebase/app';
// These imports load individual services into the firebase namespace.
import 'firebase/auth';
import 'firebase/database';
import 'firebase/messaging';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
ts: any ='';
constructor(public navCtrl: NavController) {
this.ts = firebase.database.ServerValue.TIMESTAMP;// To avoid unnecessary warning: unused import firebase
}
}
````
7. build without --prod will be successful
`ionic build`
8. build with --prod will now fail
`ionic build --prod`
**Output:**
````
c:\xampp\htdocs\blank1>ionic build --prod
Running app-scripts build: --prod
[20:11:41] build prod started ...
[20:11:41] clean started ...
[20:11:41] clean finished in less than 1 ms
[20:11:41] copy started ...
[20:11:41] deeplinks started ...
[20:11:42] deeplinks finished in 32 ms
[20:11:42] ngc started ...
[20:11:50] ngc finished in 8.87 s
[20:11:50] preprocess started ...
[20:11:50] preprocess finished in less than 1 ms
[20:11:50] webpack started ...
[20:11:51] copy finished in 9.42 s
````
**My `ionic info`:**
```
c:\xampp\htdocs\blank1>ionic info
cli packages: (C:\Users\Desk06\AppData\Roaming\npm\node_modules)
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
global packages:
cordova (Cordova CLI) : 8.0.0
local packages:
@ionic/app-scripts : 3.1.10
Cordova Platforms : android 7.0.0
Ionic Framework : ionic-angular 3.9.2
System:
Android SDK Tools : 26.1.1
Node : v8.11.1
npm : 6.0.1
OS : Windows 10
Environment Variables:
ANDROID_HOME : E:\android_sdks
Misc:
backend : pro
```
**Other Information:**
```
c:\xampp\htdocs\blank1>ionic build
Running app-scripts build:
[20:03:52] build dev started ...
[20:03:52] clean started ...
[20:03:52] clean finished in 16 ms
[20:03:52] copy started ...
[20:03:53] deeplinks started ...
[20:03:53] deeplinks finished in 15 ms
[20:03:53] transpile started ...
[20:03:57] transpile finished in 4.26 s
[20:03:57] preprocess started ...
[20:03:57] preprocess finished in 1 ms
[20:03:57] webpack started ...
[20:03:57] copy finished in 4.48 s
[20:04:04] webpack finished in 6.71 s
[20:04:04] sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[20:04:05] sass finished in 1.48 s
[20:04:05] postprocess started ...
[20:04:05] postprocess finished in 15 ms
[20:04:05] lint started ...
[20:04:05] build dev finished in 12.71 s
> ionic cordova prepare --no-build
> cordova prepare
Android Studio project detected
[20:04:11] lint finished in 6.09 s
c:\xampp\htdocs\blank1>ionic build --prod
Running app-scripts build: --prod
[20:04:28] build prod started ...
[20:04:28] clean started ...
[20:04:28] clean finished in less than 1 ms
[20:04:28] copy started ...
[20:04:28] deeplinks started ...
[20:04:28] deeplinks finished in 16 ms
[20:04:28] ngc started ...
[20:04:37] ngc finished in 8.62 s
[20:04:37] preprocess started ...
[20:04:37] preprocess finished in less than 1 ms
[20:04:37] webpack started ...
[20:04:37] copy finished in 9.10 s
[20:05:06] webpack finished in 28.59 s
[20:05:06] uglify started ...
[20:05:06] sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[20:05:07] sass finished in 1.73 s
[20:05:07] cleancss started ...
[20:05:10] cleancss finished in 2.50 s
[20:05:21] uglify finished in 15.87 s
[20:05:21] postprocess started ...
[20:05:21] postprocess finished in less than 1 ms
[20:05:21] lint started ...
[20:05:21] build prod finished in 53.26 s
> ionic cordova prepare --no-build
> cordova prepare
Android Studio project detected
[20:05:28] lint finished in 6.48 s
c:\xampp\htdocs\blank1>npm i -s firebase
[grpc] Success: "c:\xampp\htdocs\blank1\node_modules\grpc\src\node\extension_binary\node-v57-win32-x64-unknown\grpc_node.node" is installed via remote
+ firebase@5.1.0
added 110 packages from 59 contributors in 42.995s
[!] 1 vulnerability found [3788 packages audited]
Severity: 1 Low
Run `npm audit` for more detail
c:\xampp\htdocs\blank1>ionic build
Running app-scripts build:
[20:10:52] build dev started ...
[20:10:52] clean started ...
[20:10:52] clean finished in 16 ms
[20:10:52] copy started ...
[20:10:53] deeplinks started ...
[20:10:53] deeplinks finished in 31 ms
[20:10:53] transpile started ...
[20:10:57] transpile finished in 4.59 s
[20:10:57] preprocess started ...
[20:10:57] preprocess finished in less than 1 ms
[20:10:57] webpack started ...
[20:10:57] copy finished in 4.86 s
[20:11:04] webpack finished in 7.35 s
[20:11:04] sass started ...
Without `from` option PostCSS could generate wrong source map and will not find Browserslist config. Set it to CSS file path or to `undefined` to prevent this warning.
[20:11:06] sass finished in 1.81 s
[20:11:06] postprocess started ...
[20:11:06] postprocess finished in 47 ms
[20:11:06] lint started ...
[20:11:06] build dev finished in 14.10 s
> ionic cordova prepare --no-build
> cordova prepare
[20:11:13] lint finished in 6.97 s
Android Studio project detected
c:\xampp\htdocs\blank1>ionic build --prod
Running app-scripts build: --prod
[20:11:41] build prod started ...
[20:11:41] clean started ...
[20:11:41] clean finished in less than 1 ms
[20:11:41] copy started ...
[20:11:41] deeplinks started ...
[20:11:42] deeplinks finished in 32 ms
[20:11:42] ngc started ...
[20:11:50] ngc finished in 8.87 s
[20:11:50] preprocess started ...
[20:11:50] preprocess finished in less than 1 ms
[20:11:50] webpack started ...
[20:11:51] copy finished in 9.42 s
```
Contributor guide
Assessment
This issue has not been assessed yet.