Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Using Gulp's 'gulp-useref' For a Full Build Pipeline

Ben Zuba
Ben Zuba
13,575 Points

userref asset out of date, updated code to v3 can't get app.js and css files to build in dist folder.

Heres my html task following v-3 standards

gulp.task('compileSass', function() {
  return gulp.src(options.src + "/scss/application.scss")
      .pipe(maps.init())
      .pipe(sass())
      .pipe(maps.write('./'))
      .pipe(gulp.dest(options.src + '/css'));
});
```javascript 





```javascript
'use strict';

const gulp = require('gulp'),
  concat = require('gulp-concat'),
  uglify = require('gulp-uglify'),
  rename = require('gulp-rename'),
  sass = require('gulp-sass'),
  maps = require('gulp-sourcemaps'),
  del = require('del'),
  useref = require('gulp-useref'),
  iff = require('gulp-if'),
  csso = require('gulp-csso');

  var options = {
    src: 'src',
    dist: 'dist'
  }

// gulp.task('concatScripts', function() {
//   return gulp.src([
//    'js/jquery.js',
//    'js/sticky/jquery.sticky.js',
//    'js/main.js'])
//   .pipe(maps.init())
//   .pipe(concat('app.js'))
//   .pipe(maps.write('./'))
//   .pipe(gulp.dest('js'));
// });

// gulp.task('minifyScripts',["concatScripts"], function(){
//   return gulp.src('js/app.js')
//   .pipe(uglify())
//   .pipe(rename('app.min.js'))
//   .pipe(gulp.dest('js'));
// });


gulp.task('compileSass', function() {
  return gulp.src(options.src + "/scss/application.scss")
      .pipe(maps.init())
      .pipe(sass())
      .pipe(maps.write('./'))
      .pipe(gulp.dest(options.src + '/css'));
});

gulp.task('watchFiles', function() {
  gulp.watch(options.src + '/scss/**/*.scss', ['compileSass']);
})

gulp.task('clean', function() {
  del([options.dist, options.src + '/css/application.css*']);
});

gulp.task('html', ['compileSass'], () => {
  return gulp.src('/src/index.html')
    .pipe(useref())
    .pipe(iff('*.js', uglify()))
    .pipe(iff('*.css', csso()))
    .pipe(gulp.dest(options.dist));
});



gulp.task("build", ['html'], function() {
  return gulp.src([options.src + "/img/**", options.src + "/fonts/**"], { base: options.src})
            .pipe(gulp.dest(options.dist));
});

gulp.task('serve', ['watchFiles']);

gulp.task("default", ["clean"], function() {
  gulp.start('build');
});

```javascript
Ben Zuba
Ben Zuba
13,575 Points

So I figured it out.

in the index.html there are commented out code 
    <!-- build:css css/app.min.css -->
    <link rel="stylesheet" href="css/application.css">
    <!-- endbuild -->
```html 
and 
```html
    <!-- build:js js/app.js -->
    <script src="js/jquery.js"></script>
    <script src="js/sticky/jquery.sticky.js"></script>
    <script src="js/main.js"></script>
    <!-- endbuild -->
```html 

I didn't see this in the course files, but when ended it build the files. I guess now my question is what is reading these commented out build and endbuild lines? it wasn't mentioned in the video so I assumed they were just comments for the developer.

1 Answer

Watch the video; he mentions the commented out code at 13:41