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

Support !default and !global as !important

Open alexander-akait opened this issue 8 years ago • 3 comments

Example

$var: /* comment 1 */ all /* comment 2 */ !import /* comment 3 */ ; /* comment 4 */

Parse as

Declaration {
      raws: 
       { before: '',
         between: ': /* comment 1 */ ',
         important: ' !important /* comment 3 */ ',
         value: { value: 'all ', raw: 'all /* comment 2 */' } },
      type: 'css-decl',
      source: 
       { start: { line: 1, column: 1 },
         input: 
          Input {
            css: '$var: /* comment 1 */ all /* comment 2 */ !important /* comment 3 */ ; /* comment 4 */\n',
            id: '<input css 1>' },
         end: { line: 1, column: 70 } },
      prop: '$var',
      important: true,
      value: 'all ' }

It should be easy for implement, if you accept i will do PR.

Use case - for prettier, don't eat comment and don't parse inside package. Thanks!

alexander-akait avatar Feb 06 '18 12:02 alexander-akait

We can set Declaration#raws.scssGlobal and scssDefault if property name is started with $.

I think it will be better to not remove !global from value (in this case CSS stringifier will stringify it back).

PR is welcome :).

ai avatar Feb 06 '18 13:02 ai

@ai we add !global when have flag scssGlobal, maybe we can add value have with global and add scssValue without !global ?

alexander-akait avatar Feb 06 '18 13:02 alexander-akait

Yeap, raws.scssValue is good idea.

ai avatar Feb 06 '18 13:02 ai