From 24a8e782d8b2adb208d9cfb8659450395e2e2a77 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 20 Dec 2017 09:04:52 +0100 Subject: [PATCH] Add bootstrap analyzer and optimize build --- client/package.json | 6 +- client/src/app/+admin/admin.module.ts | 2 + client/src/app/shared/shared.module.ts | 3 - .../shared/video-description.component.ts | 2 +- client/src/sass/include/_bootstrap.scss | 56 +++++++++++++++++++ client/yarn.lock | 54 +++++++++++++++++- package.json | 3 +- scripts/build/client.sh | 2 +- scripts/client-report.sh | 5 ++ 9 files changed, 123 insertions(+), 10 deletions(-) create mode 100644 client/src/sass/include/_bootstrap.scss create mode 100755 scripts/client-report.sh diff --git a/client/package.json b/client/package.json index 7e23d4d75..ba0a318bc 100644 --- a/client/package.json +++ b/client/package.json @@ -16,7 +16,8 @@ "lint": "standard && tslint --type-check --project ./tsconfig.json -c ./tslint.json 'src/app/**/*.ts'", "webpack": "webpack", "ng": "ng", - "postinstall": "npm rebuild node-sass" + "postinstall": "npm rebuild node-sass", + "webpack-bundle-analyzer": "webpack-bundle-analyzer" }, "license": "GPLv3", "dependencies": {}, @@ -37,6 +38,7 @@ "@ngx-loading-bar/http-client": "^1.0.0-rc.1", "@ngx-meta/core": "^4.0.1", "@types/core-js": "^0.9.28", + "@types/lodash-es": "^4.17.0", "@types/markdown-it": "^0.0.4", "@types/node": "^8.0.33", "@types/video.js": "6.2.0", @@ -50,6 +52,7 @@ "extract-text-webpack-plugin": "^3.0.2", "file-loader": "^1.1.5", "html-webpack-plugin": "^2.19.0", + "lodash-es": "^4.17.4", "markdown-it": "^8.4.0", "ngx-bootstrap": "2.0.0-beta.9", "ngx-chips": "1.6.1", @@ -74,6 +77,7 @@ "video.js": "^6.2.0", "videojs-dock": "^2.0.2", "webpack": "^3.3.0", + "webpack-bundle-analyzer": "^2.9.1", "webtorrent": "^0.98.0", "zone.js": "~0.8.5" } diff --git a/client/src/app/+admin/admin.module.ts b/client/src/app/+admin/admin.module.ts index c0b006e73..74ceb25ef 100644 --- a/client/src/app/+admin/admin.module.ts +++ b/client/src/app/+admin/admin.module.ts @@ -1,5 +1,6 @@ import { NgModule } from '@angular/core' import { TabsModule } from 'ngx-bootstrap/tabs' +import { DataTableModule } from 'primeng/components/datatable/datatable' import { SharedModule } from '../shared' import { AdminRoutingModule } from './admin-routing.module' import { AdminComponent } from './admin.component' @@ -16,6 +17,7 @@ import { VideoBlacklistComponent, VideoBlacklistListComponent } from './video-bl imports: [ AdminRoutingModule, TabsModule.forRoot(), + DataTableModule, SharedModule ], diff --git a/client/src/app/shared/shared.module.ts b/client/src/app/shared/shared.module.ts index 5af118c98..a5c56cb46 100644 --- a/client/src/app/shared/shared.module.ts +++ b/client/src/app/shared/shared.module.ts @@ -10,7 +10,6 @@ import { ModalModule } from 'ngx-bootstrap/modal' import { InfiniteScrollModule } from 'ngx-infinite-scroll' import { BytesPipe, KeysPipe, NgPipesModule } from 'ngx-pipes' import { SharedModule as PrimeSharedModule } from 'primeng/components/common/shared' -import { DataTableModule } from 'primeng/components/datatable/datatable' import { AUTH_INTERCEPTOR_PROVIDER } from './auth' import { DeleteButtonComponent } from './misc/delete-button.component' @@ -39,7 +38,6 @@ import { VideoService } from './video/video.service' BsDropdownModule.forRoot(), ModalModule.forRoot(), - DataTableModule, PrimeSharedModule, InfiniteScrollModule, NgPipesModule @@ -66,7 +64,6 @@ import { VideoService } from './video/video.service' BsDropdownModule, ModalModule, - DataTableModule, PrimeSharedModule, InfiniteScrollModule, BytesPipe, diff --git a/client/src/app/videos/+video-edit/shared/video-description.component.ts b/client/src/app/videos/+video-edit/shared/video-description.component.ts index 9b77a27e6..34dbc21a6 100644 --- a/client/src/app/videos/+video-edit/shared/video-description.component.ts +++ b/client/src/app/videos/+video-edit/shared/video-description.component.ts @@ -1,10 +1,10 @@ import { Component, forwardRef, Input, OnInit } from '@angular/core' import { ControlValueAccessor, NG_VALUE_ACCESSOR } from '@angular/forms' -import { truncate } from 'lodash' import 'rxjs/add/operator/debounceTime' import 'rxjs/add/operator/distinctUntilChanged' import { Subject } from 'rxjs/Subject' import { MarkdownService } from '../../shared' +import truncate from 'lodash-es/truncate' @Component({ selector: 'my-video-description', diff --git a/client/src/sass/include/_bootstrap.scss b/client/src/sass/include/_bootstrap.scss new file mode 100644 index 000000000..e72d1def2 --- /dev/null +++ b/client/src/sass/include/_bootstrap.scss @@ -0,0 +1,56 @@ +/*! + * Bootstrap v3.3.7 (http://getbootstrap.com) + * Copyright 2011-2016 Twitter, Inc. + * Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE) + */ + +// Core variables and mixins +@import "bootstrap/variables"; +@import "bootstrap/mixins"; + +// Reset and dependencies +@import "bootstrap/normalize"; +@import "bootstrap/print"; +@import "bootstrap/glyphicons"; + +// Core CSS +@import "bootstrap/scaffolding"; +@import "bootstrap/type"; +@import "bootstrap/code"; +@import "bootstrap/grid"; +@import "bootstrap/tables"; +@import "bootstrap/forms"; +@import "bootstrap/buttons"; + +// Components +@import "bootstrap/component-animations"; +@import "bootstrap/dropdowns"; +@import "bootstrap/button-groups"; +@import "bootstrap/input-groups"; +@import "bootstrap/navs"; +@import "bootstrap/navbar"; +@import "bootstrap/breadcrumbs"; +@import "bootstrap/pagination"; +@import "bootstrap/pager"; +@import "bootstrap/labels"; +@import "bootstrap/badges"; +@import "bootstrap/jumbotron"; +@import "bootstrap/thumbnails"; +@import "bootstrap/alerts"; +@import "bootstrap/progress-bars"; +@import "bootstrap/media"; +@import "bootstrap/list-group"; +@import "bootstrap/panels"; +@import "bootstrap/responsive-embed"; +@import "bootstrap/wells"; +@import "bootstrap/close"; + +// Components w/ JavaScript +@import "bootstrap/modals"; +@import "bootstrap/tooltip"; +@import "bootstrap/popovers"; +@import "bootstrap/carousel"; + +// Utility classes +@import "bootstrap/utilities"; +@import "bootstrap/responsive-utilities"; diff --git a/client/yarn.lock b/client/yarn.lock index 10f15bcd6..10af86a55 100644 --- a/client/yarn.lock +++ b/client/yarn.lock @@ -217,6 +217,16 @@ version "0.9.43" resolved "https://registry.yarnpkg.com/@types/core-js/-/core-js-0.9.43.tgz#65d646c5e8c0cd1bdee37065799f9d3d48748253" +"@types/lodash-es@^4.17.0": + version "4.17.0" + resolved "https://registry.yarnpkg.com/@types/lodash-es/-/lodash-es-4.17.0.tgz#ed9044d62ee36a93e0650b112701986b1c74c766" + dependencies: + "@types/lodash" "*" + +"@types/lodash@*": + version "4.14.91" + resolved "https://registry.yarnpkg.com/@types/lodash/-/lodash-4.14.91.tgz#794611b28056d16b5436059c6d800b39d573cd3a" + "@types/magnet-uri@*": version "5.1.1" resolved "https://registry.yarnpkg.com/@types/magnet-uri/-/magnet-uri-5.1.1.tgz#861aaf64c92a3137dd848fefc55cd352a8ea851a" @@ -295,7 +305,7 @@ acorn@^4.0.3: version "4.0.13" resolved "https://registry.yarnpkg.com/acorn/-/acorn-4.0.13.tgz#105495ae5361d697bd195c825192e1ad7f253787" -acorn@^5.0.0, acorn@^5.2.1: +acorn@^5.0.0, acorn@^5.1.1, acorn@^5.2.1: version "5.2.1" resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.2.1.tgz#317ac7821826c22c702d66189ab8359675f135d7" @@ -1938,6 +1948,10 @@ domutils@1.5.1: dom-serializer "0" domelementtype "1" +duplexer@^0.1.1: + version "0.1.1" + resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.1.tgz#ace6ff808c1ce66b57d1ebf97977acb02334cfc1" + duplexify@^3.1.2, duplexify@^3.4.2: version "3.5.1" resolved "https://registry.yarnpkg.com/duplexify/-/duplexify-3.5.1.tgz#4e1516be68838bc90a49994f0b39a6e5960befcd" @@ -1957,7 +1971,7 @@ ee-first@1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/ee-first/-/ee-first-1.1.1.tgz#590c61156b0ae2f4f0255732a158b266bc56b21d" -ejs@^2.5.7: +ejs@^2.5.6, ejs@^2.5.7: version "2.5.7" resolved "https://registry.yarnpkg.com/ejs/-/ejs-2.5.7.tgz#cc872c168880ae3c7189762fd5ffc00896c9518a" @@ -2349,7 +2363,7 @@ exports-loader@^0.6.3: loader-utils "^1.0.2" source-map "0.5.x" -express@^4.16.2: +express@^4.15.2, express@^4.16.2: version "4.16.2" resolved "https://registry.yarnpkg.com/express/-/express-4.16.2.tgz#e35c6dfe2d64b7dca0a5cd4f21781be3299e076c" dependencies: @@ -2489,6 +2503,10 @@ filename-regex@^2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26" +filesize@^3.5.9: + version "3.5.11" + resolved "https://registry.yarnpkg.com/filesize/-/filesize-3.5.11.tgz#1919326749433bb3cf77368bd158caabcc19e9ee" + filestream@^4.0.0: version "4.1.3" resolved "https://registry.yarnpkg.com/filestream/-/filestream-4.1.3.tgz#948fcaade8221f715f5ecaddc54862faaacc9325" @@ -2864,6 +2882,12 @@ graceful-fs@^4.1.11, graceful-fs@^4.1.2, graceful-fs@^4.1.6: version "4.1.11" resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658" +gzip-size@^3.0.0: + version "3.0.0" + resolved "https://registry.yarnpkg.com/gzip-size/-/gzip-size-3.0.0.tgz#546188e9bdc337f673772f81660464b389dce520" + dependencies: + duplexer "^0.1.1" + handle-thing@^1.2.5: version "1.2.5" resolved "https://registry.yarnpkg.com/handle-thing/-/handle-thing-1.2.5.tgz#fd7aad726bf1a5fd16dfc29b2f7a6601d27139c4" @@ -3823,6 +3847,10 @@ locate-path@^2.0.0: p-locate "^2.0.0" path-exists "^3.0.0" +lodash-es@^4.17.4: + version "4.17.4" + resolved "https://registry.yarnpkg.com/lodash-es/-/lodash-es-4.17.4.tgz#dcc1d7552e150a0640073ba9cb31d70f032950e7" + lodash._baseassign@^3.0.0: version "3.2.0" resolved "https://registry.yarnpkg.com/lodash._baseassign/-/lodash._baseassign-3.2.0.tgz#8c38a099500f215ad09e59f1722fd0c52bfe0a4e" @@ -4616,6 +4644,10 @@ onetime@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/onetime/-/onetime-1.1.0.tgz#a1f7838f8314c516f05ecefcbc4ccfe04b4ed789" +opener@^1.4.3: + version "1.4.3" + resolved "https://registry.yarnpkg.com/opener/-/opener-1.4.3.tgz#5c6da2c5d7e5831e8ffa3964950f8d6674ac90b8" + opn@^5.1.0, opn@~5.1.0: version "5.1.0" resolved "https://registry.yarnpkg.com/opn/-/opn-5.1.0.tgz#72ce2306a17dbea58ff1041853352b4a8fc77519" @@ -7159,6 +7191,22 @@ wbuf@^1.1.0, wbuf@^1.7.2: dependencies: minimalistic-assert "^1.0.0" +webpack-bundle-analyzer@^2.9.1: + version "2.9.1" + resolved "https://registry.yarnpkg.com/webpack-bundle-analyzer/-/webpack-bundle-analyzer-2.9.1.tgz#c2c8e03e8e5768ed288b39ae9e27a8b8d7b9d476" + dependencies: + acorn "^5.1.1" + chalk "^1.1.3" + commander "^2.9.0" + ejs "^2.5.6" + express "^4.15.2" + filesize "^3.5.9" + gzip-size "^3.0.0" + lodash "^4.17.4" + mkdirp "^0.5.1" + opener "^1.4.3" + ws "^3.3.1" + webpack-concat-plugin@^1.4.2: version "1.4.2" resolved "https://registry.yarnpkg.com/webpack-concat-plugin/-/webpack-concat-plugin-1.4.2.tgz#b60bbb626ce5001911809d6e2329fa32f4978a88" diff --git a/package.json b/package.json index 51434b86c..71da491be 100644 --- a/package.json +++ b/package.json @@ -47,7 +47,8 @@ "ts-node": "ts-node", "tslint": "tslint", "travis": "scripty", - "release": "scripty" + "release": "scripty", + "client-report": "scripty" }, "dependencies": { "async": "^2.0.0", diff --git a/scripts/build/client.sh b/scripts/build/client.sh index 8e8da7cbc..e3137df37 100755 --- a/scripts/build/client.sh +++ b/scripts/build/client.sh @@ -4,5 +4,5 @@ cd client || exit -1 rm -rf ./dist ./compiled -npm run ng build -- --prod +npm run ng build -- --prod --stats-json NODE_ENV=production npm run webpack -- --config webpack/webpack.video-embed.js diff --git a/scripts/client-report.sh b/scripts/client-report.sh new file mode 100755 index 000000000..586cc2e47 --- /dev/null +++ b/scripts/client-report.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +cd client || exit -1 + +npm run webpack-bundle-analyzer ./dist/stats.json -- 2.41.0