From 77780900b750572a41e06aff5051e5b029551c76 Mon Sep 17 00:00:00 2001 From: "Jamie.Rees" Date: Thu, 11 May 2017 16:27:51 +0100 Subject: [PATCH] bundling changes --- Ombi/Ombi/gulpfile.js | 51 ++++++++++++++++++------ Ombi/Ombi/typings/globals/globals.d.ts | 13 +++++- Ombi/Ombi/wwwroot/app/app.component.ts | 5 ++- Ombi/Ombi/wwwroot/app/text-loader.ts | 3 ++ Ombi/Ombi/wwwroot/systemjs.config.js | 9 ++++- Ombi/Ombi/wwwroot/systemjs.config.js.map | 2 +- Ombi/Ombi/wwwroot/systemjs.config.ts | 9 ++++- 7 files changed, 74 insertions(+), 18 deletions(-) create mode 100644 Ombi/Ombi/wwwroot/app/text-loader.ts diff --git a/Ombi/Ombi/gulpfile.js b/Ombi/Ombi/gulpfile.js index 0b46a534a..c7eb1cc4a 100644 --- a/Ombi/Ombi/gulpfile.js +++ b/Ombi/Ombi/gulpfile.js @@ -125,11 +125,18 @@ var paths = { dest: './lib/primeng/' } ], - sass: { // Simple sass->css compilation - src: ['./Styles/**/*.scss', '!./Styles/primeng/**'], - dest: './css/', - filter: '**/*.css' - }, + sass: [ // Simple sass->css compilation + { + src: ['./Styles/**/*.scss', '!./Styles/primeng/**'], + dest: './css/', + filter: '**/*.css' + }, + { + src: path.join(wwwroot, 'app/**/*.scss'), + dest: './app/', + filter: '**/*.css' + } + ], bundle: { // This is the config for the bundler, you shouldn't need to change this root: './', dest: './lib/bundle.js', @@ -142,6 +149,17 @@ var paths = { defaultExtension: 'js' } }, + map: { + text: 'app/text-loader' + }, + meta: { + '*.css': { + loader: 'text' + }, + '*.html': { + loader: 'text' + } + }, paths: { '*': 'lib/*', 'app/*': 'app/*' @@ -241,12 +259,18 @@ gulp.task('modules', function () { }) gulp.task('sass', function () { - return gulp.src(paths.sass.src) - .pipe(changed(paths.sass.dest)) - .pipe(gulpif(global.full, sourcemaps.init())) - .pipe(sass({ outputStyle: global.full ? 'compressed' : 'nested' }).on('error', sass.logError)) - .pipe(gulpif(global.full, sourcemaps.write('maps'))) - .pipe(gulp.dest(path.join(paths.wwwroot, paths.sass.dest))) + var streams = [] + for (let module of paths.sass) { + streams.push( + gulp.src(module.src) + .pipe(changed(module.dest, { extension: '.css' })) + .pipe(gulpif(global.full, sourcemaps.init())) + .pipe(sass({ outputStyle: global.full ? 'compressed' : 'nested' }).on('error', sass.logError)) + .pipe(gulpif(global.full, sourcemaps.write('maps'))) + .pipe(gulp.dest(path.join(paths.wwwroot, module.dest))) + ); + } + return merge(streams); }); @@ -262,7 +286,8 @@ gulp.task('bundle', ['typescript_firstrun'], function () { gulp.task('clean', function () { return del([ - paths.sass.dest + paths.sass.filter, + ...paths.npm.src.map(x => path.join(paths.npm.dest, x + "**")), + ...paths.sass.map(m => m.filter ? path.join(m.dest, m.filter) : m.dest), paths.lib.dest, paths.bundle.dest, ...paths.modules.map(m => m.dest), @@ -307,6 +332,6 @@ gulp.task('publish', callback => runSequence('fullvar', 'full', 'typescript', 'b // Auto compiles sass files on change, note that this doesn't seem to pick up new files at the moment gulp.task('watch', function () { - gulp.watch(paths.sass.src, ['sass']); + gulp.watch([].concat(...paths.sass.map(x => typeof (x.src) === "string" ? [x.src] : x.src)), ['sass']); gulp.watch('./Styles/**/*.css', ['libcss']); // legacy css }); diff --git a/Ombi/Ombi/typings/globals/globals.d.ts b/Ombi/Ombi/typings/globals/globals.d.ts index b9c873dfc..18b55ec7c 100644 --- a/Ombi/Ombi/typings/globals/globals.d.ts +++ b/Ombi/Ombi/typings/globals/globals.d.ts @@ -2,4 +2,15 @@ declare var module: any; declare var require: any; -declare var localStorage: any; \ No newline at end of file +declare var localStorage: any; + + +declare module "*.css" { + let string: string; + export default string; +} + +declare module "*.html" { + let string: string; + export default string; +} \ No newline at end of file diff --git a/Ombi/Ombi/wwwroot/app/app.component.ts b/Ombi/Ombi/wwwroot/app/app.component.ts index d02f76986..8acf63019 100644 --- a/Ombi/Ombi/wwwroot/app/app.component.ts +++ b/Ombi/Ombi/wwwroot/app/app.component.ts @@ -7,10 +7,13 @@ import { IdentityService } from './services/identity.service'; import { ICustomizationSettings } from './interfaces/ISettings'; + +import template from './app.component.html'; + @Component({ selector: 'ombi', moduleId: module.id, - templateUrl: './app.component.html' + templateUrl: template }) export class AppComponent implements OnInit { diff --git a/Ombi/Ombi/wwwroot/app/text-loader.ts b/Ombi/Ombi/wwwroot/app/text-loader.ts new file mode 100644 index 000000000..59b7c95db --- /dev/null +++ b/Ombi/Ombi/wwwroot/app/text-loader.ts @@ -0,0 +1,3 @@ +export var translate = function (this: any, load: any) { + return "exports.default = " + JSON.stringify(load.source) + ";"; +} \ No newline at end of file diff --git a/Ombi/Ombi/wwwroot/systemjs.config.js b/Ombi/Ombi/wwwroot/systemjs.config.js index 79a38f763..5284cc265 100644 --- a/Ombi/Ombi/wwwroot/systemjs.config.js +++ b/Ombi/Ombi/wwwroot/systemjs.config.js @@ -6,7 +6,14 @@ System.config({ defaultExtension: 'js' } }, - map: { app: '../app' } + map: { + app: '../app', + text: '../app/text-loader' + }, + meta: { + '*.css': { loader: 'text' }, + '*.html': { loader: 'text' } + } }); System.import('bundle').then(function () { System.import('/app/main'); diff --git a/Ombi/Ombi/wwwroot/systemjs.config.js.map b/Ombi/Ombi/wwwroot/systemjs.config.js.map index 1a2f3a3c3..3f8b04ad4 100644 --- a/Ombi/Ombi/wwwroot/systemjs.config.js.map +++ b/Ombi/Ombi/wwwroot/systemjs.config.js.map @@ -1 +1 @@ -{"version":3,"file":"systemjs.config.js","sourceRoot":"","sources":["systemjs.config.ts"],"names":[],"mappings":";AAAA,MAAM,CAAC,MAAM,CAAC;IACV,OAAO,EAAE,MAAM;IACf,QAAQ,EAAE;QACN,GAAG,EAAE;YACD,gBAAgB,EAAE,IAAI;SACzB;KACJ;IACD,GAAG,EAAE,EAAE,GAAG,EAAE,QAAQ,EAAE;CACzB,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC;IACzB,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAA"} \ No newline at end of file +{"version":3,"file":"systemjs.config.js","sourceRoot":"","sources":["systemjs.config.ts"],"names":[],"mappings":";AAAA,MAAM,CAAC,MAAM,CAAC;IACV,OAAO,EAAE,MAAM;IACf,QAAQ,EAAE;QACN,GAAG,EAAE;YACD,gBAAgB,EAAE,IAAI;SACzB;KACJ;IACD,GAAG,EAAE;QACD,GAAG,EAAE,QAAQ;QACb,IAAI,EAAE,oBAAoB;KAC7B;IACD,IAAI,EAAE;QACF,OAAO,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;QAC3B,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;KAC/B;CACJ,CAAC,CAAA;AAEF,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC;IACzB,MAAM,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;AAC/B,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/Ombi/Ombi/wwwroot/systemjs.config.ts b/Ombi/Ombi/wwwroot/systemjs.config.ts index be7c0a005..c1d87fda1 100644 --- a/Ombi/Ombi/wwwroot/systemjs.config.ts +++ b/Ombi/Ombi/wwwroot/systemjs.config.ts @@ -5,7 +5,14 @@ defaultExtension: 'js' } }, - map: { app: '../app' } + map: { + app: '../app', + text: '../app/text-loader' + }, + meta: { + '*.css': { loader: 'text' }, + '*.html': { loader: 'text' } + } }) System.import('bundle').then(() => {