vue3-yuanma/packages/compiler-sfc/src/stylePluginTrim.ts

19 lines
433 B
TypeScript
Raw Normal View History

import { PluginCreator } from 'postcss'
2019-11-07 10:58:15 +08:00
const trimPlugin: PluginCreator<{}> = () => {
return {
postcssPlugin: 'vue-sfc-trim',
Once(root) {
root.walk(({ type, raws }) => {
if (type === 'rule' || type === 'atrule') {
if (raws.before) raws.before = '\n'
if ('after' in raws && raws.after) raws.after = '\n'
}
})
2019-11-07 10:58:15 +08:00
}
}
}
trimPlugin.postcss = true
export default trimPlugin