diff --git a/README.md b/README.md index 83b170c4..29d00dbd 100644 --- a/README.md +++ b/README.md @@ -65,7 +65,7 @@ But I think keeping first division by file type: scripts, styles, partials. * image optimization * Unit test (karma) * e2e test (Protratctor) -* **TODO** *0.2* partials bundeling in js +* *0.2* ng html2js * **TODO** lazy * **TODO** browser sync diff --git a/app/files.json b/app/files.json index 41fe2a4d..dfa86069 100644 --- a/app/files.json +++ b/app/files.json @@ -11,7 +11,6 @@ "test/e2e" ], "copies": [ - "gulp/build.js", "gulp/e2e-tests.js", "gulp/server.js", "gulp/unit-tests.js", @@ -29,6 +28,7 @@ "package.json", "bower.json", "gulpfile.js", + "gulp/build.js", "app/index.html", "app/scripts/main/main-ctrl.js", "test/unit/main.js" diff --git a/app/templates/_package.json b/app/templates/_package.json index c1ef88d4..b86e298e 100644 --- a/app/templates/_package.json +++ b/app/templates/_package.json @@ -24,6 +24,9 @@ "gulp-ngmin": "^0.2.0", "gulp-rev": "^0.3.2", "gulp-rev-replace": "^0.1.0", + "gulp-ng-html2js": "~0.1.6", + "gulp-minify-html": "~0.1.3", + "gulp-inject": "~0.4.1", "jshint-stylish": "^0.1.5", "opn": "^0.1.1", "wiredep": "^1.4.3", diff --git a/app/templates/app/_index.html b/app/templates/app/_index.html index 8b567529..dd47e35e 100644 --- a/app/templates/app/_index.html +++ b/app/templates/app/_index.html @@ -43,9 +43,11 @@ - + + + diff --git a/app/templates/gulp/build.js b/app/templates/gulp/_build.js similarity index 77% rename from app/templates/gulp/build.js rename to app/templates/gulp/_build.js index 7e3b6aab..62be170c 100644 --- a/app/templates/gulp/build.js +++ b/app/templates/gulp/_build.js @@ -19,11 +19,32 @@ gulp.task('scripts', function () { .pipe($.size()); }); -gulp.task('html', ['styles', 'scripts'], function () { +gulp.task('partials', function () { + return gulp.src('app/partials/**/*.html') + .pipe($.minifyHtml({ + empty: true, + spare: true, + quotes: true + })) + .pipe($.ngHtml2js({ + moduleName: "<%= appname %>", + prefix: "partials/" + })) + .pipe(gulp.dest(".tmp/partials")) + .pipe($.size()); +}); + +gulp.task('html', ['styles', 'scripts', 'partials'], function () { var jsFilter = $.filter('**/*.js'); var cssFilter = $.filter('**/*.css'); return gulp.src('app/*.html') + .pipe($.inject(gulp.src('.tmp/partials/**/*.js'), { + read: false, + starttag: '', + addRootSlash: false, + ignorePath: '.tmp' + })) .pipe($.useref.assets()) .pipe($.rev()) .pipe(jsFilter) @@ -40,12 +61,6 @@ gulp.task('html', ['styles', 'scripts'], function () { .pipe($.size()); }); -gulp.task('partials', function () { - return gulp.src('app/partials/**/*.html') - .pipe(gulp.dest('dist/partials')) - .pipe($.size()); -}); - gulp.task('images', function () { return gulp.src('app/images/**/*') .pipe($.cache($.imagemin({ diff --git a/test/deps/package.json b/test/deps/package.json index 5fbd59e4..7267cf9b 100644 --- a/test/deps/package.json +++ b/test/deps/package.json @@ -32,7 +32,10 @@ "karma-phantomjs-launcher": "^0.1.4", "gulp-protractor": "0.0.7", "protractor": "~0.22.0", - "require-dir": "~0.1.0" + "require-dir": "~0.1.0", + "gulp-ng-html2js": "~0.1.6", + "gulp-minify-html": "~0.1.3", + "gulp-inject": "~0.4.1" }, "engines": { "node": ">=0.10.0"