11import { Logger } from './logger/logger' ;
2- import { getSystemData , readFileAsync , writeFileAsync } from './util/helpers' ;
32import { BuildContext } from './util/interfaces' ;
43import { purgeSourceMapsIfNeeded } from './util/source-maps' ;
54import { removeUnusedFonts } from './optimization/remove-unused-fonts' ;
6- import * as path from 'path' ;
75
86
97export function postprocess ( context : BuildContext ) {
@@ -19,46 +17,7 @@ export function postprocess(context: BuildContext) {
1917
2018function postprocessWorker ( context : BuildContext ) {
2119 return Promise . all ( [
22- addIonicGlobal ( context ) ,
2320 purgeSourceMapsIfNeeded ( context ) ,
2421 removeUnusedFonts ( context )
2522 ] ) ;
2623}
27-
28-
29- function addIonicGlobal ( context : BuildContext ) {
30- const outputFilePath = path . join ( context . buildDir , context . outputJsFileName ) ;
31-
32- return readFileAsync ( outputFilePath ) . then ( outputContent => {
33- const ionicGlobal = buildIonicGlobal ( context ) ;
34-
35- if ( outputContent . indexOf ( ionicGlobal ) === - 1 ) {
36- outputContent += ionicGlobal ;
37- return writeFileAsync ( outputFilePath , outputContent ) ;
38- }
39- } ) ;
40- }
41-
42-
43- function buildIonicGlobal ( context : BuildContext ) {
44- if ( ( < any > context ) . windowIonic ) {
45- // just a quick way to cache this to avoid unnecessary readFiles
46- return ( < any > context ) . windowIonic ;
47- }
48-
49- const systemData = getSystemData ( context . rootDir ) ;
50-
51- let output = `
52- (function(w){
53- var i = w.Ionic = w.Ionic || {};
54- ${ systemData . ionicFramework ? `i.version = '${ systemData . ionicFramework } ';` : '' }
55- ${ systemData . angularCore ? `i.angular = '${ systemData . angularCore } ';` : '' }
56- ${ systemData . ionicNative ? `i.ionicNative = '${ systemData . ionicNative } ';` : '' }
57- })(window);` ;
58-
59- // real quick minification hack
60- output = output . replace ( / \s / g, '' ) ;
61- output = output . replace ( 'vari=' , 'var i=' ) ;
62-
63- return ( < any > context ) . windowIonic = `\n\n${ output } ` ;
64- }
0 commit comments