A
A
Adel Khalitov2017-04-04 01:51:36
Sass
Adel Khalitov, 2017-04-04 01:51:36

Why text disappears when saving scss file?

var gulp         = require('gulp'),
    sass         = require('gulp-sass'),
    autoprefixer = require('gulp-autoprefixer'),
    csso         = require('gulp-csso'),
    rename       = require('gulp-rename'),
    browserSync  = require('browser-sync').create(),
    concat       = require('gulp-concat'),
    uglify       = require('gulp-uglify'),
    pug          = require('gulp-pug'),
    notify       = require('gulp-notify'),
    del          = require('del'),
    uncss        = require('gulp-uncss');

gulp.task('browser-sync', ['styles', 'pug', 'scripts'], function() {
    browserSync.init({
        server: {
            baseDir: "./app"
        },
        notify: false
    });
});

gulp.task('pug', function() {
  	return gulp.src('app/pug/*.pug')
    .pipe(pug({
      pretty: true
    })
    	.on( 'error', notify.onError(
      {
        message: "<%= error.message %>",
        title  : "PUG Error!"
      } ) )
    )
    .pipe(gulp.dest('app/'));
});

gulp.task('styles', function () {
  return gulp.src('app/sass/**/*.scss')
  .pipe(sass({
    includePaths: require('node-bourbon').includePaths
  }).on('error', sass.logError))
  .pipe(rename({suffix: '.min', prefix : ''}))
  .pipe(autoprefixer({browsers: ['last 15 versions'], cascade: false}))
  .pipe(csso({
    comments: false
  })) //minificator
  .pipe(gulp.dest('app/css'))
  .pipe(browserSync.stream());
});

gulp.task('scripts', function() {
  return gulp.src([
    './app/libs/modernizr/modernizr.js',
    './app/libs/jquery/jquery-1.11.2.min.js',
    './app/libs/waypoints/waypoints.min.js',
    './app/libs/animate/animate-css.js',
    ])
    .pipe(concat('libs.js'))
    // .pipe(uglify()) //Minify libs.js
    .pipe(gulp.dest('./app/js/'));
});


gulp.task('watch', function () {
  gulp.watch('app/sass/**/*.scss', ['styles']);
  gulp.watch('app/libs/**/*.js', ['scripts']);
  gulp.watch('app/js/**/*.js').on("change", browserSync.reload);
  gulp.watch('app/**/*.html').on('change', browserSync.reload);
  gulp.watch('app/pug/**/*.pug', ['pug'], browserSync.reload);
});

gulp.task('default', ['browser-sync', 'watch']);

That is, when you save the *.scss file, the text on the screen disappears, although if you look at the page code, then everything is fine.
But if you refresh the page, then everything returns, then when you save * .scss again.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alex Clear, 2019-03-07
@SaveLolliPoP

I removed caching from the browser, it helped me.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question