Skip to content

Commit

Permalink
html2js to bundle partials
Browse files Browse the repository at this point in the history
  • Loading branch information
Swiip committed May 15, 2014
1 parent f924ad5 commit e21e650
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 11 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion app/files.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"test/e2e"
],
"copies": [
"gulp/build.js",
"gulp/e2e-tests.js",
"gulp/server.js",
"gulp/unit-tests.js",
Expand All @@ -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"
Expand Down
3 changes: 3 additions & 0 deletions app/templates/_package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
4 changes: 3 additions & 1 deletion app/templates/app/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,11 @@
<!-- endbower -->
<!-- endbuild -->

<!-- build:js scripts/main.js -->
<!-- build:js({app,.tmp}) scripts/main.js -->
<script src="scripts/<%= appname %>.js"></script>
<script src="scripts/main/main-ctrl.js"></script>
<!-- inject:partials -->
<!-- endinject -->
<!-- endbuild -->

</body>
Expand Down
29 changes: 22 additions & 7 deletions app/templates/gulp/build.js → app/templates/gulp/_build.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: '<!-- inject:partials -->',
addRootSlash: false,
ignorePath: '.tmp'
}))
.pipe($.useref.assets())
.pipe($.rev())
.pipe(jsFilter)
Expand All @@ -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({
Expand Down
5 changes: 4 additions & 1 deletion test/deps/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit e21e650

Please sign in to comment.