From a23508adc9339ee615d7d1d037d6579a9d56df93 Mon Sep 17 00:00:00 2001 From: Matt Jeanes Date: Mon, 17 Apr 2017 22:40:15 +0100 Subject: [PATCH] Fixed bundling and various improvements - Fixed uglifyjs (apparently gulp-uglify was too new?!, fixes #1386) - Updated to latest practices from https://github.com/MattJeanes/AngularBasic - Fix primeng loading roboto (moved fonts lib from fonts to css/fonts) - Upgrade to ngx-infinite-scroll from angular2-infinite-scroll and move it to npm auto-installer - Remove weird content inclusion in csproj and just include all of wwwroot - Upgrade to Angular 4.0.2 and TypeScript 2.3.0 --- Ombi/Ombi/Ombi.csproj | 86 +------------------ Ombi/Ombi/bundleconfig.json | 24 ------ Ombi/Ombi/gulpfile.js | 44 ++++++---- Ombi/Ombi/package.json | 28 +++--- Ombi/Ombi/wwwroot/app/app.module.ts | 2 +- .../app/requests/request.component.html | 7 -- 6 files changed, 44 insertions(+), 147 deletions(-) delete mode 100644 Ombi/Ombi/bundleconfig.json diff --git a/Ombi/Ombi/Ombi.csproj b/Ombi/Ombi/Ombi.csproj index 672e1f83d..6f609d293 100644 --- a/Ombi/Ombi/Ombi.csproj +++ b/Ombi/Ombi/Ombi.csproj @@ -8,90 +8,7 @@ - - - - - - PreserveNewest - - - - - - - PreserveNewest - - - PreserveNewest - - - PreserveNewest - - - - - - - PreserveNewest - - - - - - - - - - - PreserveNewest - - - - - - - - - - - - - - PreserveNewest - - - - - - - - - - - - - - - - - - PreserveNewest - - - - - - - - - - - - - - - + @@ -134,5 +51,6 @@ + diff --git a/Ombi/Ombi/bundleconfig.json b/Ombi/Ombi/bundleconfig.json deleted file mode 100644 index 6d3f9a57a..000000000 --- a/Ombi/Ombi/bundleconfig.json +++ /dev/null @@ -1,24 +0,0 @@ -// Configure bundling and minification for the project. -// More info at https://go.microsoft.com/fwlink/?LinkId=808241 -[ - { - "outputFileName": "wwwroot/css/site.min.css", - // An array of relative input file paths. Globbing patterns supported - "inputFiles": [ - "wwwroot/css/site.css" - ] - }, - { - "outputFileName": "wwwroot/js/site.min.js", - "inputFiles": [ - "wwwroot/js/site.js" - ], - // Optionally specify minification options - "minify": { - "enabled": true, - "renameLocals": true - }, - // Optionally generate .map file - "sourceMap": false - } -] diff --git a/Ombi/Ombi/gulpfile.js b/Ombi/Ombi/gulpfile.js index fead077d4..07d74e81c 100644 --- a/Ombi/Ombi/gulpfile.js +++ b/Ombi/Ombi/gulpfile.js @@ -15,6 +15,7 @@ var cleancss = require('gulp-clean-css'); var filter = require('gulp-filter'); var systemJSBuilder = require('systemjs-builder'); var run = require('gulp-run'); +var fs = require('fs'); var wwwroot = './wwwroot'; @@ -32,16 +33,13 @@ var paths = { '@angular/http', '@angular/router', '@angular/forms', - + '@angular/platform-browser/animations', + 'ngx-infinite-scroll' ], dest: './lib' }, lib: { // These are simple single-file dependencies with optional rename, for more files or folders use modules src: [ - { - file: './node_modules/@angular/platform-browser/bundles/platform-browser-animations.umd.js', - rename: '@angular/platform-browser/animations' - }, { file: './node_modules/systemjs/dist/system.src.js', rename: 'system' @@ -89,7 +87,7 @@ var paths = { src: [ './node_modules/primeng/resources/themes/omega/fonts/*' ], - dest: './fonts/' + dest: './css/fonts/' } ], libimages: [ // Library images @@ -120,12 +118,7 @@ var paths = { name: 'primeng', src: './node_modules/primeng/**/*.js', dest: './lib/primeng/' - }, - { - name: "angular2-infinite-scroll", - src: ['./node_modules/angular2-infinite-scroll/**/*.js', '!./node_modules/angular2-infinite-scroll/bundles/**/*.js'], - dest: "./lib/angular2-infinite-scroll/" - }, + } ], sass: { // Simple sass->css compilation src: ['./Styles/**/*.scss', '!./Styles/primeng/**'], @@ -252,7 +245,7 @@ gulp.task('sass', function () { }); -gulp.task('bundle', function () { +gulp.task('bundle', ['typescript_firstrun'], function () { var builder = new systemJSBuilder(paths.bundle.root); builder.config(paths.bundle.config); @@ -264,15 +257,32 @@ gulp.task('bundle', function () { gulp.task('clean', function () { return del([ - paths.sass.dest, + paths.sass.dest + paths.sass.filter, paths.lib.dest, paths.bundle.dest, - ...paths.modules.map(m => m.dest) + ...paths.modules.map(m => m.dest), + ...paths.libcss.map(m => m.dest + (m.filter ? m.filter : '')), + ...paths.libfonts.map(m => m.dest) ].map(x => path.join(paths.wwwroot, x)), { force: true }); }) -gulp.task('typescript', function () { +// Runs the TypeScript compiler +function runTSC() { return run('tsc').exec(); +} + +// Allows app to bundle libs on first run by compiling the app first, only compiles if entry point doesn't exist +gulp.task('typescript_firstrun', function () { + var bundle = path.join(paths.wwwroot, paths.bundle.bundle); + var exists = fs.existsSync(bundle); + if (!exists) { + console.log(`'${bundle}' doesn't exist - compiling TypeScript`); + return runTSC(); + } +}) + +gulp.task('typescript', function () { + return runTSC(); }); uglify().on('error', @@ -285,7 +295,7 @@ gulp.task('fullvar', () => { global.full = true }); gulp.task('copy', ['lib', 'libcss', 'libfonts', 'libimages', 'npm', 'modules']); gulp.task('compile', callback => runSequence('copy', 'sass', callback)); gulp.task('build', callback => runSequence('compile', 'bundle', callback)); -gulp.task('full', callback => runSequence(/*'clean',*/ 'compile', callback)); +gulp.task('full', callback => runSequence('clean', 'compile', callback)); // Use this in a build server environment to compile and bundle everything gulp.task('publish', callback => runSequence('fullvar', 'full', 'typescript', 'bundle', callback)); diff --git a/Ombi/Ombi/package.json b/Ombi/Ombi/package.json index 643b975b2..ed6898e79 100644 --- a/Ombi/Ombi/package.json +++ b/Ombi/Ombi/package.json @@ -3,22 +3,21 @@ "version": "1.0.0", "private": true, "dependencies": { - "@angular/animations": "^4.0.0", - "@angular/common": "^4.0.0", - "@angular/compiler": "^4.0.0", - "@angular/compiler-cli": "^4.0.0", - "@angular/core": "^4.0.0", - "@angular/forms": "^4.0.0", - "@angular/http": "^4.0.0", - "@angular/platform-browser": "^4.0.0", - "@angular/platform-browser-dynamic": "^4.0.0", - "@angular/platform-server": "^4.0.0", + "@angular/animations": "^4.0.2", + "@angular/common": "^4.0.2", + "@angular/compiler": "^4.0.2", + "@angular/compiler-cli": "^4.0.2", + "@angular/core": "^4.0.2", + "@angular/forms": "^4.0.2", + "@angular/http": "^4.0.2", + "@angular/platform-browser": "^4.0.2", + "@angular/platform-browser-dynamic": "^4.0.2", + "@angular/platform-server": "^4.0.2", "@angular/router": "^4.0.0", "@types/jquery": "^2.0.33", "@types/systemjs": "^0.20.2", - "angular2-infinite-scroll": "^0.3.4", - "angular2-moment": "^1.3.3", "angular2-jwt": "0.2.0", + "angular2-moment": "^1.3.3", "bootstrap": "3.3.6", "core-js": "^2.4.1", "del": "^2.2.2", @@ -32,17 +31,18 @@ "gulp-sass": "^2.3.2", "gulp-sourcemaps": "^1.9.0", "gulp-systemjs-builder": "^0.15.0", - "gulp-uglify": "^2.1.2", + "gulp-uglify": "^1.5.4", "jquery": "2.2.1", "merge-stream": "^1.0.1", "nanoscroller": "^0.8.7", + "ngx-infinite-scroll": "^0.4.1", "primeng": "^2.0.5", "run-sequence": "^1.2.2", "rxjs": "^5.0.3", "systemjs": "^0.19.41", "systemjs-builder": "^0.15.34", "tether": "^1.4.0", - "typescript": "^2.2.1", + "typescript": "^2.3.0", "zone.js": "^0.8.5" } } diff --git a/Ombi/Ombi/wwwroot/app/app.module.ts b/Ombi/Ombi/wwwroot/app/app.module.ts index 90e5d86da..e74ce4265 100644 --- a/Ombi/Ombi/wwwroot/app/app.module.ts +++ b/Ombi/Ombi/wwwroot/app/app.module.ts @@ -8,7 +8,7 @@ import { AppComponent } from './app.component'; import { RouterModule, Routes } from '@angular/router'; import { HttpModule } from '@angular/http'; -import { InfiniteScrollModule } from 'angular2-infinite-scroll/angular2-infinite-scroll' +import { InfiniteScrollModule } from 'ngx-infinite-scroll' import { SearchComponent } from './search/search.component'; import { RequestComponent } from './requests/request.component'; diff --git a/Ombi/Ombi/wwwroot/app/requests/request.component.html b/Ombi/Ombi/wwwroot/app/requests/request.component.html index 4c43df249..91c88bce7 100644 --- a/Ombi/Ombi/wwwroot/app/requests/request.component.html +++ b/Ombi/Ombi/wwwroot/app/requests/request.component.html @@ -78,13 +78,6 @@ {{/if_eq}} --> - - - - - - -