U
U
uzi_no_uzi2018-06-08 17:49:18
Node.js
uzi_no_uzi, 2018-06-08 17:49:18

Why is the gulp-sourcemaps plugin not working?

There is such a gulpfile

var gulp = require('gulp');
var less = require('gulp-less');
var concat = require('gulp-concat');
var uglify = require('gulp-uglify');
var cssmin = require('gulp-cssmin');
var autoprefixer = require('gulp-autoprefixer');
var browserSync = require('browser-sync');
var sourcemaps = require('gulp-sourcemaps');
var htmlmin = require('gulp-htmlmin');



var path = {

  build: {
    html: 'dist/',
    js: 'dist/js',
    css: 'dist/css',
    img: 'dist/img',
    fonts: 'dist/fonts'
  },

  src: {
    html: 'app/*.html',
    js: 'app/js/*.js',
    css: 'app/css/*.css',
    img: 'app/img/**/*.*',
    fonts: 'fonts/**/*.*'
  },

  watch: {
    html: 'app/*.html',
    js: 'app/js/*.js',
    less: 'app/less/**/*.less',
    img: 'app/img/**/*.*',
    fonts: 'fonts/**/*.*'
  }
}

gulp.task('browser-sync', function() {
    browserSync.init({
        server: {
            baseDir: "dist/"
        }
    });
});

gulp.task('less', function() {
  return gulp.src('app/less/styles.less')
  .pipe(less())
  .pipe(gulp.dest('app/css/'))
  .pipe(browserSync.reload({stream: true}))
})


gulp.task('css', function() {
  return gulp.src(path.src.css)
  .pipe(sourcemaps.init())
  .pipe(concat('styles.css'))
  .pipe(cssmin())
  .pipe(autoprefixer({
    browsers: ['last 4 versions'],
    cascade: false
  }))
  .pipe(sourcemaps.write())
  .pipe(gulp.dest(path.build.css))
  .pipe(browserSync.reload({stream: true}))
})

gulp.task('html', function() {
  return gulp.src(path.src.html)
  .pipe(htmlmin())
  .pipe(gulp.dest(path.build.html))
  .pipe(browserSync.reload({stream: true}))
})


gulp.task('build', ['browser-sync'], function() {
  gulp.watch(path.watch.less, ['less', 'css']);
  gulp.watch(path.watch.html, ['html'])
})

The fact is that
sourcemaps
doesn't work as it should. I can not understand what the problem is, I tried to change the sequence of pipes in the task, but this did not lead to anything. Maybe someone faced a similar problem? I would be grateful for any hints.
5b1a976a705fc217829256.jpeg
Here is a screenshot of the problem itself, everything goes in one line and it is impossible to debug the code after minification.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question