2021-02-04 21:37:55 +08:00
|
|
|
import { PluginCreator } from 'postcss'
|
2019-11-07 10:58:15 +08:00
|
|
|
|
2021-02-04 21:37:55 +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
|
|
|
}
|
2021-02-04 21:37:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
trimPlugin.postcss = true
|
|
|
|
export default trimPlugin
|