gulp-useref
gulp-useref copied to clipboard
Migration from John Papa version 2 to version 3.0.0 half working.
Hi. There. At first, thanks for the awesome library. However, i got trouble to migrate from John Papa version 2 to version 3. I think i am not understanding 'searchPath'.
Here is original version 2 from JohnPapa pluralsigh course: gulp.task('optimize', ['inject'], function(){ log('optimizing the javascript, css, html'); var useref = $.useref; var assets = $.useref.assets({searchPath: './'}); var templateCache = config.temp + config.templateCache.file; return gulp .src(config.index) .pipe($.plumber()) //TODO process .pipe($.inject(gulp.src(templateCache, {read: false}), { starttag: '' })) .pipe(assets) .pipe(assets.restore()) .pipe(useref()) .pipe(gulp.dest(config.build)); });
Here is version 3 after follow documentation, i cant get var useref = $.useref({searchPath: './'}) working. So i have to use array option of useref. This version got .tmp folder working, bower_components folder working but not src folder. Any ideas?
gulp.task('optimize', ['inject'], function(){ log('optimizing the javascript, css, html'); var useref = $.useref({searchPath: ['.tmp', 'src' , './bower_components']}); var templateCache = config.temp + config.templateCache.file; return gulp .src(config.index) .pipe($.plumber()) //TODO process .pipe($.inject(gulp.src(templateCache, {read: false}), { starttag: '' })) .pipe(useref) .pipe(gulp.dest(config.build)); });
BTW: my folder structure is .tmp, bower_components, src and others) under root directory.
And this is key placeholder in my index.html
<!-- build:css styles/lib.css-->
<!-- bower:css -->
<!-- endbower -->
<!-- endbuild -->
<!-- build:css styles/app.css-->
<!-- inject:css -->
<!-- endinject -->
<!-- endbuild -->
<!-- build:js js/lib.js-->
<!-- bower:js -->
<!-- endbower -->
<!-- endbuild -->
<!-- build:js js/app.js-->
<!-- inject:js -->
<!-- endinject -->
<!-- inject:templates:js -->
<!-- endinject -->
<!-- endbuild -->
Are you getting any errors in the output?
No errors. Just failed to find src folder silently via {searchPath: ['.tmp', 'src' , './bower_components']}. .tmp and bower_components folder are good. Is there any way i can convert version 2 {searchPath: './'} to version 3?
I have set up a github repository to replicate this issue. url is: https://github.com/peterhe2000/pluralsight-gulp-johnPapa/tree/master/pluralsight-gulp-master
Need run following command: $ npm install $ bower install $ gulp optimize
Issue is in https://github.com/peterhe2000/pluralsight-gulp-johnPapa/blob/master/pluralsight-gulp-master/gulpfile.js line number 145. I want to line number 145 include .tmp, src , ./bower_components. Please help.