summaryrefslogtreecommitdiff
path: root/src/stylesheets/lib/postcss-rule-per-line.js
blob: d85f5aa6958b5c01b5d4fcda81ca694db0ebe744 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
'use strict'

/**
 * Makes the minified stylesheet more readable by putting each rule on its own line and adding a trailing newline.
 */
module.exports = (opts) => {
  return {
    postcssPlugin: 'postcss-rule-per-line',
    OnceExit (root) {
      root.walk((node) => {
        if (node.type.endsWith('rule') && node.prev()) node.raws.before = '\n'
      })
      root.raws.after = '\n'
    },
  }
}

module.exports.postcss = true