diff --git a/gulpfile.js b/gulpfile.js index 3cd846f056..c1f069b683 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -17,6 +17,10 @@ var through2 = require('through2'); var runSequence = require('run-sequence'); var watch = require('gulp-watch'); var exec = require('child_process').exec; +var babel = require('gulp-babel'); +var webpack = require('gulp-webpack'); +var lazypipe = require('lazypipe'); + gulp.task('build', function() { @@ -75,30 +79,79 @@ function doubleCheckDistFiles() { } gulp.task('clean', function(done) { - del(['../angular-ionic/modules/ionic, ./angular-ionic/modules/examples/src/ionic'], done); + del(['../angular-ionic/modules/ionic, ./angular-ionic/modules/examples/src/ionic, dist/'], done); }); - -gulp.task('ionic.copy.js', function(done) { +gulp.task('ionic.transpile.js', function(done) { return gulp.src(['ionic/**/*.js', '!ionic/components/*/test/**/*']) - .pipe(gulp.dest('../angular-ionic/modules/ionic')); + .pipe(babel(babelOptions)) + //.pipe(concat('ionic.bundle.js')) + .pipe(gulp.dest('dist/js/')); }); +//gulp.task('ionic.copy.js', function(done) { +// return gulp.src(['ionic/**/*.js', '!ionic/components/*/test/**/*']) +// .pipe(gulp.dest('../angular-ionic/modules/ionic')); +//}); + var babelOptions = { + optional: ['es7.decorators'], + plugins: [ + './transformers/disable-define', + 'angular2-annotations', + 'type-assertion:after' + ] + }; + + var webpackOptions = { + module: { + loaders: [ + { + test: /\.es6$/, + loader: "babel-loader?" + JSON.stringify(babelOptions) + }, + { + test: /\.js$/, + exclude: /node_modules/, + loader: "babel-loader?" + JSON.stringify(babelOptions) + } + ] + }, + resolve: { + alias: { + 'angular2': 'angular2/es6/dev', + 'rtts_assert': 'rtts_assert/es6' + }, + modulesDirectories: [ + 'ionic2', + 'node_modules' + ], + extensions: ['', '.js', '.es6'] + }, + debug: true + } + gulp.task('ionic.examples', function() { - var indexContents = _.template( fs.readFileSync('scripts/e2e/angular.template.html') )({ - buildConfig: buildConfig - }); - + var buildTest = lazypipe() + //.pipe(babel, babelOptions) + .pipe(webpack, webpackOptions) + .pipe(createIndexHTML); + // Get each test folder with gulp.src return gulp.src('ionic/components/*/test/*/**/*') + .pipe(gulpif(/index.js$/, buildTest())) .pipe(rename(function(file) { file.dirname = file.dirname.replace(path.sep + 'test' + path.sep, path.sep) })) - .pipe(gulpif(/index.js$/, processMain())) - .pipe(gulp.dest('../angular-ionic/modules/examples/src/ionic')) + .pipe(gulp.dest('dist/examples/')) + + function createIndexHTML() { + var indexContents = _.template( + fs.readFileSync('scripts/e2e/ionic.template.html') + )({ + buildConfig: buildConfig + }); - function processMain() { return through2.obj(function(file, enc, next) { var self = this; self.push(new VinylFile({ @@ -109,7 +162,6 @@ gulp.task('ionic.examples', function() { next(null, file); }) } - }); diff --git a/package.json b/package.json index f8d1fcc29e..7188ab8aa2 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,10 @@ "name": "ionic2", "version": "0.0.0", "devDependencies": { + "babel-core": "^5.0.0", + "babel-loader": "^5.1.3", + "babel-plugin-angular2-annotations": "^1.1.0", + "babel-plugin-type-assertion": "^0.2.1", "canonical-path": "0.0.2", "connect": "^3.3.4", "del": "~1.1.1", @@ -19,11 +23,14 @@ "gulp-shell": "^0.4.0", "gulp-traceur": "^0.17.1", "gulp-watch": "^4.2.4", + "gulp-webpack": "^1.4.0", "gulp-wrap": "^0.11.0", "karma": "^0.12.31", "karma-chrome-launcher": "^0.1.7", "karma-jasmine": "^0.3.5", + "lazypipe": "^0.2.3", "lodash": "^2.4.1", + "node-libs-browser": "^0.5.2", "node-uuid": "^1.4.1", "run-sequence": "^1.1.0", "serve-static": "^1.9.2", @@ -33,13 +40,14 @@ "through2": "^0.6.3", "traceur-runtime": "0.0.59", "vinyl": "^0.4.6", + "webpack": "^1.9.10", "yargs": "^3.6.0" }, "dependencies": { - "angular2": "2.0.0-alpha.21", + "angular2": "2.0.0-alpha.25", "es6-module-loader": "^0.16.5", "hammerjs": "^2.0.4", - "rtts_assert": "^2.0.0-alpha.20", + "rtts_assert": "^2.0.0-alpha.25", "rx": "^2.4.6", "systemjs": "^0.16.8", "traceur": "0.0.87", diff --git a/scripts/e2e/ionic.template.html b/scripts/e2e/ionic.template.html new file mode 100644 index 0000000000..cb25d904a6 --- /dev/null +++ b/scripts/e2e/ionic.template.html @@ -0,0 +1,39 @@ + + +
+ + + + + + + + +