meumobi / infomobi

Ionic2 Employee App
3 stars 2 forks source link

update build script to consider both configs dev and prod #208

Open vdias38 opened 6 years ago

vdias38 commented 6 years ago

Expected behaviour

Tell us what should happen

Actual behaviour

If I build with $ npm run ionic:build --prod --env=prod it uses DEV env Using DEFAULT environment variables for PROD build.

If I build with $ ionic build --prod --env=prod it raises following error

 meu-starter.ionic-v3@0.0.1 ngsw-copy /Users/victor/Dvpt/PROJECTS/ion-employee
> cp node_modules/@angular/service-worker/ngsw-worker.js www/ "prod"

usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file
       cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... target_directory
npm ERR! code ELIFECYCLE
npm ERR! errno 64
npm ERR! meu-starter.ionic-v3@0.0.1 ngsw-copy: `cp node_modules/@angular/service-worker/ngsw-worker.js www/ "prod"`
npm ERR! Exit status 64
npm ERR! 
npm ERR! Failed at the meu-starter.ionic-v3@0.0.1 ngsw-copy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/victor/.npm/_logs/2018-10-04T17_05_38_226Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 64
npm ERR! meu-starter.ionic-v3@0.0.1 ionic:build: `ionic-app-scripts build && npm run ngsw-config && npm run ngsw-copy "--prod" "--env" "prod"`
npm ERR! Exit status 64
npm ERR! 
npm ERR! Failed at the meu-starter.ionic-v3@0.0.1 ionic:build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/victor/.npm/_logs/2018-10-04T17_05_38_397Z-debug.log
[ERROR] An error occurred while running subprocess npm.

        npm run ionic:build -- --prod --env prod exited with exit code 64.  

Steps to reproduce

1. 2. 3.

Expected responses

vdias38 commented 6 years ago

Also tested with following command $ npm run ionic:build --prod --env prod

[17:50:53]  lint finished in 31.39 s 

> meu-starter.ionic-v3@0.0.1 ngsw-config /Users/victor/Dvpt/PROJECTS/ion-employee
> ngsw-config www src/ngsw-config.json

> meu-starter.ionic-v3@0.0.1 ngsw-copy /Users/victor/Dvpt/PROJECTS/ion-employee
> cp node_modules/@angular/service-worker/ngsw-worker.js www/ "prod"

usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file
       cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... target_directory
npm ERR! code ELIFECYCLE
npm ERR! errno 64
npm ERR! meu-starter.ionic-v3@0.0.1 ngsw-copy: `cp node_modules/@angular/service-worker/ngsw-worker.js www/ "prod"`
npm ERR! Exit status 64
npm ERR! 
npm ERR! Failed at the meu-starter.ionic-v3@0.0.1 ngsw-copy script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/victor/.npm/_logs/2018-10-05T16_51_03_716Z-debug.log
npm ERR! code ELIFECYCLE
npm ERR! errno 64
npm ERR! meu-starter.ionic-v3@0.0.1 ionic:build: `ionic-app-scripts build && npm run ngsw-config && npm run ngsw-copy "prod"`
npm ERR! Exit status 64
npm ERR! 
npm ERR! Failed at the meu-starter.ionic-v3@0.0.1 ionic:build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
vdias38 commented 6 years ago

Also tried following cli but when I check www/build/main.js always find ion-employee-int

$ npm run ionic:build --env=prod --prod

> meu-starter.ionic-v3@0.0.1 ionic:build /Users/victor/Dvpt/PROJECTS/ion-employee
> ionic-app-scripts build && npm run ngsw-config && npm run ngsw-copy

...
[19:07:57]  webpack started ... 
Using PROD environment variables for PROD build.
Loading ./src/environments/environment.prod.ts
[19:07:57]  copy finished in 28.73 s 
...
$ npm run ionic:build -- --env=prod --prod

> meu-starter.ionic-v3@0.0.1 ionic:build /Users/victor/Dvpt/PROJECTS/ion-employee
> ionic-app-scripts build && npm run ngsw-config && npm run ngsw-copy "prod"
...
[19:31:46]  webpack started ... 
Using PROD environment variables for PROD build.
Loading ./src/environments/environment.prod.ts
[19:31:48]  copy finished in 35.86 s 
...
> meu-starter.ionic-v3@0.0.1 ngsw-copy /Users/victor/Dvpt/PROJECTS/ion-employee
> cp node_modules/@angular/service-worker/ngsw-worker.js www/ "prod"

usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file
       cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... target_directory
npm ERR! code ELIFECYCLE
npm ERR! errno 64
npm ERR! meu-starter.ionic-v3@0.0.1 ngsw-copy: `cp node_modules/@angular/service-worker/ngsw-worker.js www/ "prod"`
npm ERR! Exit status 64
vdias38 commented 5 years ago

$ ionic build --env=prod --prod

npm run ionic:build -- --prod --env prod ionic-app-scripts build && npm run ngsw-config && npm run ngsw-copy "--prod" "--env" "prod" Using DEFAULT environment variables for PROD build. Loading ./src/environments/environment.ts

$ npm run ionic:build --env=prod --prod

ionic-app-scripts build && npm run ngsw-config && npm run ngsw-copy Using PROD environment variables for PROD build. // BUT NOT when I check www/build/main.js always find ion-employee-int Loading ./src/environments/environment.prod.ts

If I do a grep on www/build/main.js I can see that both env files are concat

{apiKey:"AIzaSyBemLnl_Wz4U50lD3gXirvjDk5jLUbyA_M",**authDomain:"ion-employee-int.firebaseapp.com**",databaseURL:"https://ion-employ
ee-int.firebaseio.com",projectId:"ion-employee-int",storageBucket:"ion-employee-int.appspot.com",mes
sagingSenderId:"236514035211"},[]),s._12(256,S.d,void 0,[]),s._12(256,Q.a,"/",[]),s._12(256,b.l,"XSRF-TOKEN",[]),s._12(256,b.m,"X-XSRF-TOKEN",[]),s._12(256,O.a,_,[]),s._12(256,p.m,void 0,[]),s._12(256,p.l,void 0,[])])})},56:function(t,e,n){"use strict";n.d(e,"a",function(){return i});var i={production:!0,isDebugMode:!1,analyticsTrackingId:"UA-113326323-1",meumobi:{apiUrl:"https://meumobi.com"},imgServer:{url:"https://imageflow.meumobi.com/",sources:{firebase:{prefix:"https://infomobi.page.link"},meumobi:{prefix:"/uploads"}}},dynamicLinks:{url:"https://firebasedynamiclinks.googleapis.com/v1/shortLinks",prefix:"https://infomobi.page.link"},youtube:{apiKey:"AIzaSyAD49q_weB67bZX8u95G9zrXmBULqdMzas"},firebase:{apiKey:"AIzaSyBnCsnH9XAtG73lIwRuYj4dbXLyPBv0E5I",**authDomain:"ion-employee.firebaseapp
.com**",databaseURL:"https://ion-employee.firebaseio.com",projectId:"ion-employee",storageBucket:"ion-
employee.appspot.com",messagingSenderId:"961286969528"}}}
vdias38 commented 5 years ago

The behavior is unstable, implementation recommended on blog post works well BUT not on app.module. I've commented this behavior on ionic issue