D
D
dmitriu2562020-12-24 14:02:44
css
dmitriu256, 2020-12-24 14:02:44

Why does gulp-sass compile css preserve selector nesting hierarchy instead of starting on a new line?

Why is this
SASS moment happening

/*HEADER*/
.header
  padding: 8px 0
  background: #0050B3
  /*Search Form*/
  &-form
    position: relative
    width: 336px
    &__input
      width: 100%
      padding: 5px 30px 5px 12px
      border: 1px solid #D9D9D9
      border-radius: 4px
      background: #fff
      font-family: 'Source Sans Pro', sans-serif
      font-size: 14px
      font-weight: 400
      line-height: 1.57
      color: $text-color
      &::placeholder
        color: #BFBFBF


CSS looks like
/*HEADER*/
.header {
  padding: 8px 0;
  background: #0050B3;
  /*Search Form*/
  /*Navigation*/
  /*Social icons*/
  /*Info icons*/ }
  .header-form {
    position: relative;
    width: 336px; }
    .header-form__input {
      width: 100%;
      padding: 5px 30px 5px 12px;
      border: 1px solid #D9D9D9;
      border-radius: 4px;
      background: #fff;
      font-family: 'Source Sans Pro', sans-serif;
      font-size: 14px;
      font-weight: 400;
      line-height: 1.57;
      color: #595959; }
      .header-form__input::placeholder {
        color: #BFBFBF; }


When building, I use Gulp4, I used to build Gulp3 before - there were no such problems.
The source code always lined up in one line - without nesting. Block styles always on a new line
Example as before
.navigation-block {
  display: block;
  width: 100%;
  background: #373737;
  min-height: 40px;
  position: fixed;
  top: 0;
  left: 0;
  z-index: 900;
  -webkit-transition: all 0.5s ease;
  transition: all 0.5s ease;
}

.navigation-block__list {
  padding: 0;
  margin: 0;
  list-style: none;
  display: -webkit-box;
  display: flex;
  -webkit-box-orient: horizontal;
  -webkit-box-direction: normal;
  flex-direction: row;
  -webkit-box-pack: center;
  justify-content: center;
}

.navigation-block__item {
  text-align: center;
  border-left: 1px dashed #9d9d9d;
}

.navigation-block__item:first-child {
  border-left: none;
}


My gulpfile GULPv4
A piece of code that is responsible for converting styles
function styles() {
    return src('src/sass/*.sass') // Подключаем  sass файлы
        .pipe(sass())
        .pipe(concat('style.min.css')) // Конкатенируем файл
        //.pipe(autoprefixer({ overrideBrowserslist: ['last 10 versions'], grid: false })) // Создадим префиксы с помощью Autoprefixer
        //pipe(cleancss( { level: { 1: { specialComments: 0 } }/* , format: 'beautify' */ } )) // Минифицируем стили
        .pipe(dest('src/css/')) // Выгрузим результат в папку "app/css/"
        .pipe(browserSync.stream()) // Сделаем инъекцию в браузер
}

What changes need to be made to style each block on a new line in css?

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