B
B
b4rret2019-05-07 17:25:09
Preprocessors
b4rret, 2019-05-07 17:25:09

How to set the formatting style of the final file in PostCSS?

In sass, it is possible to set the formatting style of the final file using the outputStyle option, which can accept nested, compact, expanded, compressed
How to do something similar in PostCSS, and more specifically the expanded style?

gulp.task('css', function() {
  gulp.src(source + 'style.css')
  .pipe(sourcemaps.init())
  .pipe(postcss([
    postcssPartialImport({prefix: '_', extension: '.css'}),
    postcssPresetEnv({
      autoprefixer: {
        browsers: [
          "> 1%",
          "last 2 versions",
          "Android >= 4", 
          "Firefox >= 20", 
          "iOS >= 8"
        ]
      },
      features: {
        'nesting-rules': true,
        'color-mod-function': true,
        'custom-selectors': true,
        'custom-media-queries': true
      }      
    })
  ]))
  .on('error', gutil.log)
  .pipe(sourcemaps.write('.'))
  .pipe(gulp.dest(dest + 'css'));
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
b4rret, 2019-05-07
@b4rret

In general, I solved the problem with the stylefmt plugin , in particular for my case gulp-stylefmt , it seems to be recommended on the official page with plugins

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question