-
Notifications
You must be signed in to change notification settings - Fork 445
/
Copy pathweb.module.ts
107 lines (95 loc) · 3.14 KB
/
web.module.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
// angular
import { NgModule } from '@angular/core';
import { APP_BASE_HREF } from '@angular/common';
import { BrowserModule } from '@angular/platform-browser';
import { RouterModule } from '@angular/router';
import { Http } from '@angular/http';
// libs
import { StoreModule } from '@ngrx/store';
import { EffectsModule } from '@ngrx/effects';
import { StoreDevtoolsModule } from '@ngrx/store-devtools';
import { TranslateLoader } from '@ngx-translate/core';
// app
import { APP_COMPONENTS, AppComponent } from './app/components/index';
import { routes } from './app/components/app.routes';
// feature modules
import { WindowService, StorageService, ConsoleService, createConsoleTarget, provideConsoleTarget, LogTarget, LogLevel, ConsoleTarget } from './app/modules/core/services/index';
import { CoreModule, Config } from './app/modules/core/index';
import { AnalyticsModule } from './app/modules/analytics/index';
import { MultilingualModule, Languages, translateLoaderFactory, MultilingualEffects } from './app/modules/i18n/index';
import { SampleModule, SampleEffects } from './app/modules/sample/index';
import { AppReducer } from './app/modules/ngrx/index';
// config
Config.PLATFORM_TARGET = Config.PLATFORMS.WEB;
if (String('<%= BUILD_TYPE %>') === 'dev') {
// only output console logging in dev mode
Config.DEBUG.LEVEL_4 = true;
}
let routerModule = RouterModule.forRoot(routes);
if (String('<%= TARGET_DESKTOP %>') === 'true') {
Config.PLATFORM_TARGET = Config.PLATFORMS.DESKTOP;
// desktop (electron) must use hash
routerModule = RouterModule.forRoot(routes, { useHash: true });
}
declare var window, console, localStorage;
// For AoT compilation to work:
export function win() {
return window;
}
export function storage() {
return localStorage;
}
export function cons() {
return console;
}
export function consoleLogTarget(consoleService: ConsoleService) {
return new ConsoleTarget(consoleService, { minLogLevel: LogLevel.Debug });
}
let DEV_IMPORTS: any[] = [];
if (String('<%= BUILD_TYPE %>') === 'dev') {
DEV_IMPORTS = [
...DEV_IMPORTS,
StoreDevtoolsModule.instrumentOnlyWithExtension()
];
}
@NgModule({
imports: [
BrowserModule,
CoreModule.forRoot([
{ provide: WindowService, useFactory: (win) },
{ provide: StorageService, useFactory: (storage) },
{ provide: ConsoleService, useFactory: (cons) },
{ provide: LogTarget, useFactory: (consoleLogTarget), deps: [ConsoleService], multi: true }
]),
routerModule,
AnalyticsModule,
MultilingualModule.forRoot([{
provide: TranslateLoader,
deps: [Http],
useFactory: (translateLoaderFactory)
}]),
SampleModule,
// configure app state
StoreModule.provideStore(AppReducer),
EffectsModule.run(MultilingualEffects),
EffectsModule.run(SampleEffects),
// dev environment only imports
DEV_IMPORTS,
],
declarations: [
APP_COMPONENTS
],
providers: [
{
provide: APP_BASE_HREF,
useValue: '<%= APP_BASE %>'
},
// override with supported languages
{
provide: Languages,
useValue: Config.GET_SUPPORTED_LANGUAGES()
}
],
bootstrap: [AppComponent]
})
export class WebModule { }