From f3d103f311e86403ec942d9100f7dbbe510326b4 Mon Sep 17 00:00:00 2001 From: Dani Palou Date: Tue, 12 Jun 2018 12:41:24 +0200 Subject: [PATCH] MOBILE-2163 core: Copy component templates to www --- gulpfile.js | 38 +++++++++++++++++++ package.json | 5 ++- .../{ion-tabs.html => core-ion-tabs.html} | 0 src/components/ion-tabs/ion-tabs.ts | 2 +- 4 files changed, 43 insertions(+), 2 deletions(-) rename src/components/ion-tabs/{ion-tabs.html => core-ion-tabs.html} (100%) diff --git a/gulpfile.js b/gulpfile.js index d3377c5d7..3561eb76d 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -6,6 +6,8 @@ var gulp = require('gulp'), slash = require('gulp-slash'), clipEmptyFiles = require('gulp-clip-empty-files'), gutil = require('gulp-util'), + flatten = require('gulp-flatten'), + npmPath = require('path'), File = gutil.File, license = '' + '// (C) Copyright 2015 Martin Dougiamas\n' + @@ -185,6 +187,22 @@ function buildLangs(filenames, langPaths, buildDest, done) { }); } +// Delete a folder and all its contents. +function deleteFolderRecursive(path) { + if (fs.existsSync(path)) { + fs.readdirSync(path).forEach(function(file) { + var curPath = npmPath.join(path, file); + if (fs.lstatSync(curPath).isDirectory()) { + deleteFolderRecursive(curPath); + } else { + fs.unlinkSync(curPath); + } + }); + + fs.rmdirSync(path); + } +} + // List of app lang files. To be used only if cannot get it from filesystem. var appLangFiles = ['ar.json', 'bg.json', 'ca.json', 'cs.json', 'da.json', 'de.json', 'en.json', 'es-mx.json', 'es.json', 'eu.json', 'fa.json', 'fr.json', 'he.json', 'hu.json', 'it.json', 'ja.json', 'nl.json', 'pl.json', 'pt-br.json', 'pt.json', 'ro.json', @@ -269,3 +287,23 @@ gulp.task('config', function(done) { .pipe(gulp.dest(paths.src)) .on('end', done); }); + +var templatesSrc = [ + './src/components/**/*.html', + './src/core/**/components/**/*.html', + './src/core/**/component/**/*.html', + './src/addon/**/components/**/*.html', + './src/addon/**/component/**/*.html' + ], + templatesDest = './www/templates'; + +// Copy component templates to www to make compile-html work in AOT. +gulp.task('copy-component-templates', function(done) { + deleteFolderRecursive(templatesDest); + + gulp.src(templatesSrc) + .pipe(flatten()) + .pipe(gulp.dest(templatesDest)) + .on('end', done); +}); + diff --git a/package.json b/package.json index d8d0e9900..c82f02d62 100644 --- a/package.json +++ b/package.json @@ -30,7 +30,9 @@ "ionic:build": "node --max-old-space-size=16384 ./node_modules/@ionic/app-scripts/bin/ionic-app-scripts.js build", "ionic:serve": "gulp watch | ionic-app-scripts serve", "ionic:build:before": "gulp", - "ionic:watch:before": "gulp" + "ionic:watch:before": "gulp", + "ionic:build:after": "gulp copy-component-templates", + "postionic:build": "gulp copy-component-templates" }, "dependencies": { "@angular/animations": "5.2.10", @@ -86,6 +88,7 @@ "@ionic/app-scripts": "3.1.9", "gulp": "^3.9.1", "gulp-clip-empty-files": "^0.1.2", + "gulp-flatten": "^0.4.0", "gulp-rename": "^1.2.2", "gulp-slash": "^1.1.3", "through": "^2.3.8", diff --git a/src/components/ion-tabs/ion-tabs.html b/src/components/ion-tabs/core-ion-tabs.html similarity index 100% rename from src/components/ion-tabs/ion-tabs.html rename to src/components/ion-tabs/core-ion-tabs.html diff --git a/src/components/ion-tabs/ion-tabs.ts b/src/components/ion-tabs/ion-tabs.ts index a3a6bb2cc..997887afb 100644 --- a/src/components/ion-tabs/ion-tabs.ts +++ b/src/components/ion-tabs/ion-tabs.ts @@ -24,7 +24,7 @@ import { CoreUtilsProvider } from '@providers/utils/utils'; */ @Component({ selector: 'core-ion-tabs', - templateUrl: 'ion-tabs.html', + templateUrl: 'core-ion-tabs.html', encapsulation: ViewEncapsulation.None, providers: [{provide: RootNode, useExisting: forwardRef(() => CoreIonTabsComponent) }] })