trim.ts 433 B

123456789101112131415161718
  1. import { PluginCreator } from 'postcss'
  2. const trimPlugin: PluginCreator<{}> = () => {
  3. return {
  4. postcssPlugin: 'vue-sfc-trim',
  5. Once(root) {
  6. root.walk(({ type, raws }) => {
  7. if (type === 'rule' || type === 'atrule') {
  8. if (raws.before) raws.before = '\n'
  9. if ('after' in raws && raws.after) raws.after = '\n'
  10. }
  11. })
  12. }
  13. }
  14. }
  15. trimPlugin.postcss = true
  16. export default trimPlugin