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

Chase Nobles
seal-mask
.a{fill-rule:evenodd;}techdegree
Chase Nobles
Full Stack JavaScript Techdegree Student 13,633 Points

Gulp Source Maps on Minified CSS

Trying to get a sourcemap to show on the minified all.min.css in chrome when I run gulp styles.

gulp.task("concatCSS", function(){
  return gulp.src("sass/global.scss")
  .pipe(maps.init())
  .pipe(sass())
  .pipe(maps.write('./'))
  .pipe(gulp.dest('dest/styles'))
});

gulp.task('styles', ['concatCSS'], function(){
  return gulp.src("dest/styles/global.css")
  .pipe(maps.init())
  .pipe(cleanCSS({compatibility: 'ie8'}))
  .pipe(rename("all.min.css"))
  .pipe(maps.write('./'))
  .pipe(gulp.dest('dest/styles'));
});```
Adam Beer
Adam Beer
11,314 Points

Code

Wrap your code with 3 backticks (```) on the line before and after. If you specify the language after the first set of backticks, that'll help us with syntax highlighting.

      ```html
      <p>This is code!</p>
      ```
Chase Nobles
seal-mask
.a{fill-rule:evenodd;}techdegree
Chase Nobles
Full Stack JavaScript Techdegree Student 13,633 Points

It's mapping to the global.css file but not back to the individual sass files.

Tried mapping and minification in one place, but same thing. When I inspect an element on the page it references global.css which doesn't even exist in my files.

gulp.task('styles', function(){
  return gulp.src("sass/global.scss")
  .pipe(maps.init())
  .pipe(sass())
  .pipe(cleanCSS({compatibility: 'ie8'}))
  .pipe(rename("all.min.css"))
  .pipe(maps.write('./'))
  .pipe(gulp.dest('dest/styles'));
});

1 Answer

Adam Beer
Adam Beer
11,314 Points

This is my solution. This is the end of course.

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("_sass/application.scss")
        .pipe(maps.init())
        .pipe(sass())
        .pipe(maps.write('./'))
        .pipe(gulp.dest('css'));
});
Chase Nobles
seal-mask
.a{fill-rule:evenodd;}techdegree
Chase Nobles
Full Stack JavaScript Techdegree Student 13,633 Points

I'm trying to minify the css and preserve the source maps. While you compiled the Sass files here, you didn't minify the final css and maintain the sourcemaps.