postcss-import icon indicating copy to clipboard operation
postcss-import copied to clipboard

Allow outputting correct formatting with media queries

Open nwmcsween opened this issue 7 years ago • 3 comments

Example:

importfile.css:

@import 'somefile.css' (min-width: 36em);`

somefile.css:

.select {
  foo: bar;
}

Output:

@media (min-width:36em){
.select {
 foo: bar;
}
}

Desired output:

@media (min-width:36em) {
  .select {
   foo: bar;
  }
}

nwmcsween avatar Jun 03 '17 14:06 nwmcsween

Yeah, if this doesn't require a huge amount of changes (or really hurt performance), PR welcome. I'm personally not motivated to fix this since I always run the output through a minifier anyhow.

RyanZim avatar Jun 03 '17 14:06 RyanZim

Since https://github.com/postcss/postcss-import/pull/483; this also applies to @layer support.

RyanZim avatar Mar 22 '22 15:03 RyanZim

We've had similar requests for nested css transforms and decided not to implement any kind of formatting.

Formatting is best left up to linters.

Any attempt to resolve this here would end up re-implementing a full blown linter with all the user preferences. (tabs vs. spaces, where to start newlines, ...)

romainmenke avatar Jun 05 '22 09:06 romainmenke

@nwmcsween You can add a pretty printer plugin later in your PostCSS plugins config.

This seems to do exactly what you want : https://www.npmjs.com/package/postcss-prettify

romainmenke avatar Jul 23 '23 10:07 romainmenke

Yeah, I'm going to close this as out of scope.

RyanZim avatar Jul 24 '23 14:07 RyanZim