Posts

Showing posts from January, 2020

Ionic prod release build source map extractor scripts

In your angular ionic projects angular.json file look for "sourceMap" field, make it true. This will generate source map for you every time you build your project whether its prod or non prod build. Now we dont want this source map files to go in build because of security risk and also your build size will increase drastically. To resolve this we can write two custom scripts which will copy your soruce map files to some other folder. We need to call script using before build and after build hooks provided by Ionic. So alter your ionic.config.json as follows: { "name": "list-creator-app", "integrations": { "cordova": {} }, "type": "angular", "hooks": { "build:before": "./scripts/ionic-before-build.js", "build:after": "./scripts/ionic-post-build.js" } } Create scripts folder in your directory and put below script files in it. ionic-po

Shell script to upload sourcemap files to bugsnag for angular ionic project

#assuming source maps as present in 'source-map' directory in your project for f in www/*.js ; do f= $ {f#"www/"}; minifiedUrl= "http://localhost/" $f; sourceMap= "@source-map/" $f ".map" #echo $sourceMap; curl --http1.1 https://upload.bugsnag.com/ -F apiKey=<your-key-here> -F appVersion=<your-app-version-here> -F minifiedUrl=$minifiedUrl -F sourceMap=$sourceMap; done

Pinch zoom in zoom out using angular

@ViewChild ( 'img' , { static : true }) img : any; zoomLevel : number = 100 ; scaling : boolean; pinchZoom () { let oldDist = undefined; this . renderer . listen ( this . img . nativeElement , 'touchstart' , (e) => { if (e. touches . length === 2 ) { this . scaling = true; } }) ; this . renderer . listen ( this . img . nativeElement , 'touchmove' , (e) => { if ( this . scaling ) { let newDist = Math . hypot ( e. touches [ 0 ]. pageX - e. touches [ 1 ]. pageX , e. touches [ 0 ]. pageY - e. touches [ 1 ]. pageY ) ; this . zoomBy ( this . img . nativeElement , (newDist > oldDist)) ; oldDist = newDist ; } }) ; this . renderer . listen ( this . img . nativeElement , 'touchend' , (e) => { if ( this . scaling ) { this . scaling = false; } oldDist = undefined; }) ; } z