I am in the process of developing an Angular 2 application and packaging it using SystemJS/JSPM.
During the development phase, I include the app in index.html
:
<script src="jspm_packages/system.js"></script>
<script src="systemjs.config.js"></script>
<script src="systemjs.importapp.js"></script>
For bundling, I use the following command:
jspm bundle-sfx app assets/js/myapp.sfx.min.js --minify --no-mangle --skip-source-maps
I then update a version of index.html
with
<script src="assets/js/myapp.sfx.min.js" defer></script>
which replaces the three scripts mentioned above.
The starting point in my main.ts
file looks like this:
// CORE IMPORTS
import 'es6-shim';
import 'reflect-metadata';
import 'zone.js';
import 'zone.js/dist/zone';
import 'zone.js/dist/long-stack-trace-zone';
import 'rxjs';
// ADD ALL OPERATORS TO OBSERVABLES
import 'rxjs/Rx';
// APP INITIALISATION
import {bootstrap} from 'angular2/platform/browser';
import {enableProdMode} from 'angular2/core';
import {AppComponent} from './app.component';
import {ROUTER_PROVIDERS} from 'angular2/router';
bootstrap(AppComponent, [
ROUTER_PROVIDERS
]);
My challenge is to conditionally call enableProdMode()
only when I am bundling with jspm bundle-sfx
.
What would be the most effective approach to achieve this?