diff --git a/client/config/webpack.common.js b/client/config/webpack.common.js index 223f55c2e..08b8a4b09 100644 --- a/client/config/webpack.common.js +++ b/client/config/webpack.common.js @@ -5,6 +5,7 @@ const helpers = require('./helpers') */ const AssetsPlugin = require('assets-webpack-plugin') +const BundleAnalyzerPlugin = require('webpack-bundle-analyzer').BundleAnalyzerPlugin const NormalModuleReplacementPlugin = require('webpack/lib/NormalModuleReplacementPlugin') const ContextReplacementPlugin = require('webpack/lib/ContextReplacementPlugin') const CommonsChunkPlugin = require('webpack/lib/optimize/CommonsChunkPlugin') @@ -313,6 +314,30 @@ module.exports = function (options) { disabled: !AOT, tsConfig: helpers.root('tsconfig.webpack.json'), resourceOverride: helpers.root('config/resource-override.js') + }), + + new BundleAnalyzerPlugin({ + // Can be `server`, `static` or `disabled`. + // In `server` mode analyzer will start HTTP server to show bundle report. + // In `static` mode single HTML file with bundle report will be generated. + // In `disabled` mode you can use this plugin to just generate Webpack Stats JSON file by setting `generateStatsFile` to `true`. + analyzerMode: 'static', + // Path to bundle report file that will be generated in `static` mode. + // Relative to bundles output directory. + reportFilename: 'report.html', + // Automatically open report in default browser + openAnalyzer: false, + // If `true`, Webpack Stats JSON file will be generated in bundles output directory + generateStatsFile: true, + // Name of Webpack Stats JSON file that will be generated if `generateStatsFile` is `true`. + // Relative to bundles output directory. + statsFilename: 'stats.json', + // Options for `stats.toJson()` method. + // For example you can exclude sources of your modules from stats file with `source: false` option. + // See more options here: https://github.com/webpack/webpack/blob/webpack-1/lib/Stats.js#L21 + statsOptions: null, + // Log level. Can be 'info', 'warn', 'error' or 'silent'. + logLevel: 'info' }) ], diff --git a/client/package.json b/client/package.json index ea458f1d4..f4835590e 100644 --- a/client/package.json +++ b/client/package.json @@ -88,6 +88,7 @@ "add-asset-html-webpack-plugin": "^1.0.2", "codelyzer": "2.0.0-beta.4", "standard": "^8.0.0", + "webpack-bundle-analyzer": "^2.2.1", "webpack-dll-bundles-plugin": "^1.0.0-beta.5" } } diff --git a/client/src/app/admin/admin-routing.module.ts b/client/src/app/+admin/admin-routing.module.ts similarity index 97% rename from client/src/app/admin/admin-routing.module.ts rename to client/src/app/+admin/admin-routing.module.ts index cabc6df15..d3adf3f3b 100644 --- a/client/src/app/admin/admin-routing.module.ts +++ b/client/src/app/+admin/admin-routing.module.ts @@ -9,7 +9,7 @@ import { VideoAbusesRoutes } from './video-abuses'; const adminRoutes: Routes = [ { - path: 'admin', + path: '', component: AdminComponent, children: [ { diff --git a/client/src/app/admin/admin.component.ts b/client/src/app/+admin/admin.component.ts similarity index 100% rename from client/src/app/admin/admin.component.ts rename to client/src/app/+admin/admin.component.ts diff --git a/client/src/app/admin/admin.module.ts b/client/src/app/+admin/admin.module.ts similarity index 86% rename from client/src/app/admin/admin.module.ts rename to client/src/app/+admin/admin.module.ts index d3ada8ce8..db1ce2d7f 100644 --- a/client/src/app/admin/admin.module.ts +++ b/client/src/app/+admin/admin.module.ts @@ -6,7 +6,6 @@ import { FriendsComponent, FriendAddComponent, FriendListComponent, FriendServic import { RequestsComponent, RequestStatsComponent, RequestService } from './requests'; import { UsersComponent, UserAddComponent, UserListComponent, UserService } from './users'; import { VideoAbusesComponent, VideoAbuseListComponent } from './video-abuses'; -import { MenuAdminComponent } from './menu-admin.component'; import { SharedModule } from '../shared'; @NgModule({ @@ -30,14 +29,11 @@ import { SharedModule } from '../shared'; UserListComponent, VideoAbusesComponent, - VideoAbuseListComponent, - - MenuAdminComponent + VideoAbuseListComponent ], exports: [ - AdminComponent, - MenuAdminComponent + AdminComponent ], providers: [ diff --git a/client/src/app/admin/friends/friend-add/friend-add.component.html b/client/src/app/+admin/friends/friend-add/friend-add.component.html similarity index 100% rename from client/src/app/admin/friends/friend-add/friend-add.component.html rename to client/src/app/+admin/friends/friend-add/friend-add.component.html diff --git a/client/src/app/admin/friends/friend-add/friend-add.component.scss b/client/src/app/+admin/friends/friend-add/friend-add.component.scss similarity index 100% rename from client/src/app/admin/friends/friend-add/friend-add.component.scss rename to client/src/app/+admin/friends/friend-add/friend-add.component.scss diff --git a/client/src/app/admin/friends/friend-add/friend-add.component.ts b/client/src/app/+admin/friends/friend-add/friend-add.component.ts similarity index 100% rename from client/src/app/admin/friends/friend-add/friend-add.component.ts rename to client/src/app/+admin/friends/friend-add/friend-add.component.ts diff --git a/client/src/app/admin/friends/friend-add/index.ts b/client/src/app/+admin/friends/friend-add/index.ts similarity index 100% rename from client/src/app/admin/friends/friend-add/index.ts rename to client/src/app/+admin/friends/friend-add/index.ts diff --git a/client/src/app/admin/friends/friend-list/friend-list.component.html b/client/src/app/+admin/friends/friend-list/friend-list.component.html similarity index 100% rename from client/src/app/admin/friends/friend-list/friend-list.component.html rename to client/src/app/+admin/friends/friend-list/friend-list.component.html diff --git a/client/src/app/admin/friends/friend-list/friend-list.component.scss b/client/src/app/+admin/friends/friend-list/friend-list.component.scss similarity index 100% rename from client/src/app/admin/friends/friend-list/friend-list.component.scss rename to client/src/app/+admin/friends/friend-list/friend-list.component.scss diff --git a/client/src/app/admin/friends/friend-list/friend-list.component.ts b/client/src/app/+admin/friends/friend-list/friend-list.component.ts similarity index 100% rename from client/src/app/admin/friends/friend-list/friend-list.component.ts rename to client/src/app/+admin/friends/friend-list/friend-list.component.ts diff --git a/client/src/app/admin/friends/friend-list/index.ts b/client/src/app/+admin/friends/friend-list/index.ts similarity index 100% rename from client/src/app/admin/friends/friend-list/index.ts rename to client/src/app/+admin/friends/friend-list/index.ts diff --git a/client/src/app/admin/friends/friends.component.ts b/client/src/app/+admin/friends/friends.component.ts similarity index 100% rename from client/src/app/admin/friends/friends.component.ts rename to client/src/app/+admin/friends/friends.component.ts diff --git a/client/src/app/admin/friends/friends.routes.ts b/client/src/app/+admin/friends/friends.routes.ts similarity index 100% rename from client/src/app/admin/friends/friends.routes.ts rename to client/src/app/+admin/friends/friends.routes.ts diff --git a/client/src/app/admin/friends/index.ts b/client/src/app/+admin/friends/index.ts similarity index 100% rename from client/src/app/admin/friends/index.ts rename to client/src/app/+admin/friends/index.ts diff --git a/client/src/app/admin/friends/shared/friend.model.ts b/client/src/app/+admin/friends/shared/friend.model.ts similarity index 100% rename from client/src/app/admin/friends/shared/friend.model.ts rename to client/src/app/+admin/friends/shared/friend.model.ts diff --git a/client/src/app/admin/friends/shared/friend.service.ts b/client/src/app/+admin/friends/shared/friend.service.ts similarity index 100% rename from client/src/app/admin/friends/shared/friend.service.ts rename to client/src/app/+admin/friends/shared/friend.service.ts diff --git a/client/src/app/admin/friends/shared/index.ts b/client/src/app/+admin/friends/shared/index.ts similarity index 100% rename from client/src/app/admin/friends/shared/index.ts rename to client/src/app/+admin/friends/shared/index.ts diff --git a/client/src/app/admin/index.ts b/client/src/app/+admin/index.ts similarity index 82% rename from client/src/app/admin/index.ts rename to client/src/app/+admin/index.ts index b75ff9b51..2f47a3cc3 100644 --- a/client/src/app/admin/index.ts +++ b/client/src/app/+admin/index.ts @@ -4,4 +4,3 @@ export * from './users'; export * from './admin-routing.module'; export * from './admin.module'; export * from './admin.component'; -export * from './menu-admin.component'; diff --git a/client/src/app/admin/requests/index.ts b/client/src/app/+admin/requests/index.ts similarity index 100% rename from client/src/app/admin/requests/index.ts rename to client/src/app/+admin/requests/index.ts diff --git a/client/src/app/admin/requests/request-stats/index.ts b/client/src/app/+admin/requests/request-stats/index.ts similarity index 100% rename from client/src/app/admin/requests/request-stats/index.ts rename to client/src/app/+admin/requests/request-stats/index.ts diff --git a/client/src/app/admin/requests/request-stats/request-stats.component.html b/client/src/app/+admin/requests/request-stats/request-stats.component.html similarity index 100% rename from client/src/app/admin/requests/request-stats/request-stats.component.html rename to client/src/app/+admin/requests/request-stats/request-stats.component.html diff --git a/client/src/app/admin/requests/request-stats/request-stats.component.scss b/client/src/app/+admin/requests/request-stats/request-stats.component.scss similarity index 100% rename from client/src/app/admin/requests/request-stats/request-stats.component.scss rename to client/src/app/+admin/requests/request-stats/request-stats.component.scss diff --git a/client/src/app/admin/requests/request-stats/request-stats.component.ts b/client/src/app/+admin/requests/request-stats/request-stats.component.ts similarity index 100% rename from client/src/app/admin/requests/request-stats/request-stats.component.ts rename to client/src/app/+admin/requests/request-stats/request-stats.component.ts diff --git a/client/src/app/admin/requests/requests.component.ts b/client/src/app/+admin/requests/requests.component.ts similarity index 100% rename from client/src/app/admin/requests/requests.component.ts rename to client/src/app/+admin/requests/requests.component.ts diff --git a/client/src/app/admin/requests/requests.routes.ts b/client/src/app/+admin/requests/requests.routes.ts similarity index 100% rename from client/src/app/admin/requests/requests.routes.ts rename to client/src/app/+admin/requests/requests.routes.ts diff --git a/client/src/app/admin/requests/shared/index.ts b/client/src/app/+admin/requests/shared/index.ts similarity index 100% rename from client/src/app/admin/requests/shared/index.ts rename to client/src/app/+admin/requests/shared/index.ts diff --git a/client/src/app/admin/requests/shared/request-stats.model.ts b/client/src/app/+admin/requests/shared/request-stats.model.ts similarity index 100% rename from client/src/app/admin/requests/shared/request-stats.model.ts rename to client/src/app/+admin/requests/shared/request-stats.model.ts diff --git a/client/src/app/admin/requests/shared/request.service.ts b/client/src/app/+admin/requests/shared/request.service.ts similarity index 100% rename from client/src/app/admin/requests/shared/request.service.ts rename to client/src/app/+admin/requests/shared/request.service.ts diff --git a/client/src/app/admin/users/index.ts b/client/src/app/+admin/users/index.ts similarity index 100% rename from client/src/app/admin/users/index.ts rename to client/src/app/+admin/users/index.ts diff --git a/client/src/app/admin/users/shared/index.ts b/client/src/app/+admin/users/shared/index.ts similarity index 100% rename from client/src/app/admin/users/shared/index.ts rename to client/src/app/+admin/users/shared/index.ts diff --git a/client/src/app/admin/users/shared/user.service.ts b/client/src/app/+admin/users/shared/user.service.ts similarity index 100% rename from client/src/app/admin/users/shared/user.service.ts rename to client/src/app/+admin/users/shared/user.service.ts diff --git a/client/src/app/admin/users/user-add/index.ts b/client/src/app/+admin/users/user-add/index.ts similarity index 100% rename from client/src/app/admin/users/user-add/index.ts rename to client/src/app/+admin/users/user-add/index.ts diff --git a/client/src/app/admin/users/user-add/user-add.component.html b/client/src/app/+admin/users/user-add/user-add.component.html similarity index 100% rename from client/src/app/admin/users/user-add/user-add.component.html rename to client/src/app/+admin/users/user-add/user-add.component.html diff --git a/client/src/app/admin/users/user-add/user-add.component.ts b/client/src/app/+admin/users/user-add/user-add.component.ts similarity index 100% rename from client/src/app/admin/users/user-add/user-add.component.ts rename to client/src/app/+admin/users/user-add/user-add.component.ts diff --git a/client/src/app/admin/users/user-list/index.ts b/client/src/app/+admin/users/user-list/index.ts similarity index 100% rename from client/src/app/admin/users/user-list/index.ts rename to client/src/app/+admin/users/user-list/index.ts diff --git a/client/src/app/admin/users/user-list/user-list.component.html b/client/src/app/+admin/users/user-list/user-list.component.html similarity index 100% rename from client/src/app/admin/users/user-list/user-list.component.html rename to client/src/app/+admin/users/user-list/user-list.component.html diff --git a/client/src/app/admin/users/user-list/user-list.component.scss b/client/src/app/+admin/users/user-list/user-list.component.scss similarity index 100% rename from client/src/app/admin/users/user-list/user-list.component.scss rename to client/src/app/+admin/users/user-list/user-list.component.scss diff --git a/client/src/app/admin/users/user-list/user-list.component.ts b/client/src/app/+admin/users/user-list/user-list.component.ts similarity index 100% rename from client/src/app/admin/users/user-list/user-list.component.ts rename to client/src/app/+admin/users/user-list/user-list.component.ts diff --git a/client/src/app/admin/users/users.component.ts b/client/src/app/+admin/users/users.component.ts similarity index 100% rename from client/src/app/admin/users/users.component.ts rename to client/src/app/+admin/users/users.component.ts diff --git a/client/src/app/admin/users/users.routes.ts b/client/src/app/+admin/users/users.routes.ts similarity index 100% rename from client/src/app/admin/users/users.routes.ts rename to client/src/app/+admin/users/users.routes.ts diff --git a/client/src/app/admin/video-abuses/index.ts b/client/src/app/+admin/video-abuses/index.ts similarity index 100% rename from client/src/app/admin/video-abuses/index.ts rename to client/src/app/+admin/video-abuses/index.ts diff --git a/client/src/app/admin/video-abuses/video-abuse-list/index.ts b/client/src/app/+admin/video-abuses/video-abuse-list/index.ts similarity index 100% rename from client/src/app/admin/video-abuses/video-abuse-list/index.ts rename to client/src/app/+admin/video-abuses/video-abuse-list/index.ts diff --git a/client/src/app/admin/video-abuses/video-abuse-list/video-abuse-list.component.html b/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.html similarity index 100% rename from client/src/app/admin/video-abuses/video-abuse-list/video-abuse-list.component.html rename to client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.html diff --git a/client/src/app/admin/video-abuses/video-abuse-list/video-abuse-list.component.scss b/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.scss similarity index 100% rename from client/src/app/admin/video-abuses/video-abuse-list/video-abuse-list.component.scss rename to client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.scss diff --git a/client/src/app/admin/video-abuses/video-abuse-list/video-abuse-list.component.ts b/client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts similarity index 100% rename from client/src/app/admin/video-abuses/video-abuse-list/video-abuse-list.component.ts rename to client/src/app/+admin/video-abuses/video-abuse-list/video-abuse-list.component.ts diff --git a/client/src/app/admin/video-abuses/video-abuses.component.ts b/client/src/app/+admin/video-abuses/video-abuses.component.ts similarity index 100% rename from client/src/app/admin/video-abuses/video-abuses.component.ts rename to client/src/app/+admin/video-abuses/video-abuses.component.ts diff --git a/client/src/app/admin/video-abuses/video-abuses.routes.ts b/client/src/app/+admin/video-abuses/video-abuses.routes.ts similarity index 100% rename from client/src/app/admin/video-abuses/video-abuses.routes.ts rename to client/src/app/+admin/video-abuses/video-abuses.routes.ts diff --git a/client/src/app/app-routing.module.ts b/client/src/app/app-routing.module.ts index 900a4c5b6..f9465dc9c 100644 --- a/client/src/app/app-routing.module.ts +++ b/client/src/app/app-routing.module.ts @@ -6,6 +6,10 @@ const routes: Routes = [ path: '', redirectTo: '/videos/list', pathMatch: 'full' + }, + { + path: 'admin', + loadChildren: './+admin#AdminModule' } ]; diff --git a/client/src/app/app.module.ts b/client/src/app/app.module.ts index 10526e813..482a9b5b7 100644 --- a/client/src/app/app.module.ts +++ b/client/src/app/app.module.ts @@ -11,7 +11,6 @@ import { AppComponent } from './app.component'; import { AppState } from './app.service'; import { AccountModule } from './account'; -import { AdminModule } from './admin'; import { CoreModule } from './core'; import { LoginModule } from './login'; import { SharedModule } from './shared'; @@ -47,7 +46,6 @@ const APP_PROVIDERS = [ MetaModule.forRoot(metaConfig), AccountModule, - AdminModule, CoreModule, LoginModule, SharedModule, diff --git a/client/src/app/core/core.module.ts b/client/src/app/core/core.module.ts index 27e6ee1fb..09a6f92f5 100644 --- a/client/src/app/core/core.module.ts +++ b/client/src/app/core/core.module.ts @@ -4,7 +4,7 @@ import { HttpModule } from '@angular/http'; import { RouterModule } from '@angular/router'; import { AuthService } from './auth'; -import { MenuComponent } from './menu'; +import { MenuComponent, MenuAdminComponent } from './menu'; import { throwIfAlreadyLoaded } from './module-import-guard'; @NgModule({ @@ -13,8 +13,14 @@ import { throwIfAlreadyLoaded } from './module-import-guard'; HttpModule, RouterModule ], - declarations: [ MenuComponent ], - exports: [ MenuComponent ], + declarations: [ + MenuComponent, + MenuAdminComponent + ], + exports: [ + MenuComponent, + MenuAdminComponent + ], providers: [ AuthService ] }) export class CoreModule { diff --git a/client/src/app/core/menu/index.ts b/client/src/app/core/menu/index.ts index d07a1144c..ff40f26e1 100644 --- a/client/src/app/core/menu/index.ts +++ b/client/src/app/core/menu/index.ts @@ -1 +1,2 @@ export * from './menu.component'; +export * from './menu-admin.component'; diff --git a/client/src/app/admin/menu-admin.component.html b/client/src/app/core/menu/menu-admin.component.html similarity index 100% rename from client/src/app/admin/menu-admin.component.html rename to client/src/app/core/menu/menu-admin.component.html diff --git a/client/src/app/admin/menu-admin.component.ts b/client/src/app/core/menu/menu-admin.component.ts similarity index 100% rename from client/src/app/admin/menu-admin.component.ts rename to client/src/app/core/menu/menu-admin.component.ts