johnpapa / pluralsight-gulp

Starter Code for Pluralsight Course "JavaScript Build Automation with Gulp.js"
http://jpapa.me/gulpps
MIT License
158 stars 262 forks source link

Problem Minifying HTML and Putting in $templatecache #18

Open mdixon47 opened 8 years ago

mdixon47 commented 8 years ago

I am having an issue while running gulp templatecache. I have installed the dependencies gulp-angular-templatecache and gulp-minify-html. I have also added the information in the gulp.config.js file.

TYPEERROR: undefined is not a function

Assistance would be greatly appreciated.

gulpfile.js --->

gulp.task('templatecache',['clean-code'], function() { log('Creating an AngularJS $templateCache'); return gulp .src(config.htmltemplates) .pipe($.minifyHtml({empty: true})) .pipe($.angularTemplatecache(config.templateCache.file, config.templateCache.options)) .pipe(gulp.dest(config.temp)); });

gulp.config.js --->

htmltemplates: clientApp + '*/.html', templateCache: { file: 'templates.js', options: { module: 'app.core', standAlone: false, root: 'app/' } },

console info and error ---->

➜ pluralsight-gulp git:(master) ✗ gulp templatecache [10:25:39] Using gulpfile ~/sites/pluralsight-gulp/gulpfile.js [10:25:39] Starting 'clean-code'... [10:25:39] Cleaning: ./.tmp/*/.js,./build/**/_.html,./build/js/_/.js [10:25:39] Finished 'clean-code' after 82 ms [10:25:39] Starting 'templatecache'... [10:25:39] Creating an AngularJS $templateCache [10:25:39] 'templatecache' errored after 7.49 ms [10:25:39] TypeError: undefined is not a function at Gulp. (/Users/malikdixon1/sites/pluralsight-gulp/gulpfile.js:110:19) at module.exports (/Users/malikdixon1/sites/pluralsight-gulp/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:34:7) at Gulp.Orchestrator._runTask (/Users/malikdixon1/sites/pluralsight-gulp/node_modules/gulp/node_modules/orchestrator/index.js:273:3) at Gulp.Orchestrator._runStep (/Users/malikdixon1/sites/pluralsight-gulp/node_modules/gulp/node_modules/orchestrator/index.js:214:10) at /Users/malikdixon1/sites/pluralsight-gulp/node_modules/gulp/node_modules/orchestrator/index.js:279:18 at finish (/Users/malikdixon1/sites/pluralsight-gulp/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:21:8) at cb (/Users/malikdixon1/sites/pluralsight-gulp/node_modules/gulp/node_modules/orchestrator/lib/runTask.js:29:3) at /Users/malikdixon1/sites/pluralsight-gulp/node_modules/del/index.js:54:4 at module.exports (/Users/malikdixon1/sites/pluralsight-gulp/node_modules/del/node_modules/each-async/index.js:22:3) at /Users/malikdixon1/sites/pluralsight-gulp/node_modules/del/index.js:40:3

elisheva50 commented 8 years ago

I compared what you have to what I have, and found this difference: I have:

htmltemplates: clientApp + '*/.html',

and you are missing the '**/'

I'm not sure if that is the issue though, because I tried changing my code to match yours and I didn't get an error.

ghost commented 8 years ago

With these gulp versions it works fine:

    "gulp-angular-templatecache": "^1.7.0",
    "gulp-minify-html": "^1.0.4",

What @elisheva50 said, your config.templates value should be **/*.html (notice the stars). If I try your config (gulp.config.js) (code is fine btw), with my gulp tasks versions, I don't get an error, but... the template.js don't get build. I hope it helps.

Another thing that is different from mine, your clean code comment: Yours:

[10:25:39] Starting 'clean-code'...
[10:25:39] Cleaning: ./.tmp//*.js,./build//.html,./build/js//.js

Mine:

[14:49:59] Starting 'clean-code'...
[14:49:59] Cleaning: ./.tmp/**/*.js,./build/**/*.html,./build/js/**/*.js

Notice the second line (folder structure). I think you are forgetting a lot of stars, please post your full gulp config file with the correct markdown code tags.