diff --git a/demos/src/loading/app.component.ts b/demos/src/loading/app.component.ts
index b3f01e151b..978c7a9b2e 100644
--- a/demos/src/loading/app.component.ts
+++ b/demos/src/loading/app.component.ts
@@ -1,4 +1,4 @@
-import { Component, ViewEncapsulation } from '@angular/core';
+import { Component } from '@angular/core';
import { LoadingController, NavController } from 'ionic-angular';
@Component({
@@ -122,9 +122,7 @@ export class Page2 {}
@Component({
- template: '',
- styleUrls: ['styles.css'],
- encapsulation: ViewEncapsulation.None
+ template: ''
})
export class ApiDemoApp {
root = Page1;
diff --git a/demos/src/package.json b/demos/src/package.json
deleted file mode 100644
index 49a160a576..0000000000
--- a/demos/src/package.json
+++ /dev/null
@@ -1,11 +0,0 @@
-{
- "name": "ionic-demos",
- "private": true,
- "version": "1.0.0",
- "description": "demos of ionic framework",
- "author": "Ionic Team (http://ionic.io)",
- "license": "MIT",
- "dependencies": {
- "ionic-angular": "nightly"
- }
-}
diff --git a/demos/src/popover/app.component.ts b/demos/src/popover/app.component.ts
index 744d845f61..f401518131 100644
--- a/demos/src/popover/app.component.ts
+++ b/demos/src/popover/app.component.ts
@@ -1,4 +1,4 @@
-import { Component, ElementRef, ViewChild, ViewEncapsulation } from '@angular/core';
+import { Component, ElementRef, ViewChild } from '@angular/core';
import { NavParams, PopoverController } from 'ionic-angular';
@Component({
@@ -154,9 +154,7 @@ export class ApiDemoPage {
}
@Component({
- template: '',
- styleUrls: ['style.css'],
- encapsulation: ViewEncapsulation.None
+ template: ''
})
export class ApiDemoApp {
root = ApiDemoPage;
diff --git a/demos/src/tabs/app.component.ts b/demos/src/tabs/app.component.ts
index bdcd628f65..93eb66282a 100644
--- a/demos/src/tabs/app.component.ts
+++ b/demos/src/tabs/app.component.ts
@@ -1,5 +1,4 @@
-import { Component, NgModule, ViewEncapsulation } from '@angular/core';
-import { IonicApp, IonicModule } from 'ionic-angular';
+import { Component } from '@angular/core';
@Component({
template: 'johnny utah
',
@@ -8,9 +7,7 @@ export class TabPage {}
@Component({
- templateUrl: 'page.html',
- styleUrls: ['style.css'],
- encapsulation: ViewEncapsulation.None
+ templateUrl: 'page.html'
})
export class ApiDemoPage {
root = TabPage;
diff --git a/scripts/gulp/declarations.d.ts b/scripts/gulp/declarations.d.ts
new file mode 100644
index 0000000000..ecd6422d8f
--- /dev/null
+++ b/scripts/gulp/declarations.d.ts
@@ -0,0 +1,2 @@
+declare module 'rollup';
+declare module 'rollup-plugin-node-resolve';
\ No newline at end of file
diff --git a/scripts/gulp/gulpfile.ts b/scripts/gulp/gulpfile.ts
index 77ab66e7d5..dce6e63ded 100644
--- a/scripts/gulp/gulpfile.ts
+++ b/scripts/gulp/gulpfile.ts
@@ -1,6 +1,7 @@
import './tasks/build';
import './tasks/clean';
import './tasks/default';
+import './tasks/demos';
import './tasks/e2e';
import './tasks/lint';
import './tasks/release';
diff --git a/scripts/gulp/tasks/demos.ts b/scripts/gulp/tasks/demos.ts
index 50d950a38a..22b57d588f 100644
--- a/scripts/gulp/tasks/demos.ts
+++ b/scripts/gulp/tasks/demos.ts
@@ -1,5 +1,130 @@
+import { dirname, join } from 'path';
+import { exec } from 'child_process';
+import * as glob from 'glob';
+import { task } from 'gulp';
+import * as rollup from 'rollup';
+import * as nodeResolve from 'rollup-plugin-node-resolve';
+import { DEMOS_ROOT, DEMOS_SRC_ROOT} from '../constants';
+import { deleteFiles, runNgc } from '../util';
-function runNgc() {
+function doNpmInstall() {
+ return new Promise((resolve, reject) => {
+ // navigate to the demos directly
+ try {
+ process.chdir('./demos');
+ console.log('starting npm install ...');
+ exec('npm install', function(err, stdout, stderr) {
+ process.chdir('..');
+ console.log(stdout);
+ console.log(stderr);
+ if (err) {
+ reject(err);
+ } else {
+ resolve();
+ }
+ });
+ } catch (ex) {
+ reject(ex);
+ }
+ });
+}
-}
\ No newline at end of file
+function compileTests() {
+ console.log('Starting to compile tests defined via tsconfig ...');
+ return new Promise((resolve, reject) => {
+ runNgc(`${DEMOS_ROOT}/tsconfig.json`, (err) => {
+ if (err) {
+ reject(err);
+ } else {
+ resolve();
+ }
+ });
+ });
+}
+
+function rollupTests() {
+ return new Promise((resolve, reject) => {
+ glob(`${DEMOS_SRC_ROOT}/**/main.js`, null, (err: Error, files: string[]) => {
+ if (err) {
+ reject(err);
+ } else {
+ recursiveRollupHelper(files).then(() => {
+ resolve();
+ }).catch(err => {
+ reject(err);
+ });
+ }
+ });
+ });
+}
+
+function recursiveRollupHelper(files: string[]) {
+ if (!files) {
+ return Promise.reject(new Error('list of files is null'));
+ } else if ( files.length === 0) {
+ return Promise.resolve();
+ } else {
+ const outputFileName = join(dirname(files[0]), 'app.bundle.js');
+ return runRollup(files[0], outputFileName).then(() => {
+ const remainingFiles = files.concat();
+ remainingFiles.shift();
+ return recursiveRollupHelper(remainingFiles);
+ }).catch(err => {
+ return Promise.reject(err);
+ });
+ }
+}
+
+function runRollup(inputFile: string, outputFile: string): Promise {
+ console.log(`Starting rollup on ${inputFile} ... writing to ${outputFile}`);
+ return rollup.rollup({
+ entry: inputFile,
+ plugins: [
+ rollupNG2(),
+ nodeResolve()
+ ]
+ }).then(function(bundle){
+ return bundle.write({
+ format: 'iife',
+ dest: outputFile,
+ });
+ });
+}
+
+function buildDemos(done: Function) {
+ doNpmInstall()
+ .then(() => {
+ return compileTests();
+ }).then(() => {
+ return rollupTests();
+ }).then(() => {
+ done();
+ }).catch(err => {
+ done(err);
+ });
+}
+
+task('demos.build', (done: Function) => {
+ buildDemos(done);
+});
+
+export function rollupNG2() {
+ return {
+ name: 'rollupNG2',
+
+ resolveId(id: string) {
+ if (id.startsWith('rxjs/')) {
+ return `${process.cwd()}/node_modules/rxjs-es/${id.split('rxjs/').pop()}.js`;
+ }
+ }
+ };
+}
+
+function cleanDemos(done: Function) {
+ deleteFiles([`${DEMOS_SRC_ROOT}/**/*.js`, `${DEMOS_SRC_ROOT}/**/*.d.ts`, `${DEMOS_SRC_ROOT}/**/*.ngfactory.ts`, `${DEMOS_SRC_ROOT}/**/*.metadata.json`], done);
+}
+
+task('demos.clean', (done: Function) => {
+ cleanDemos(done);
+});