import { PluginCreator, Rule, AtRule } from 'postcss' import selectorParser from 'postcss-selector-parser' const animationNameRE = /^(-\w+-)?animation-name$/ const animationRE = /^(-\w+-)?animation$/ const scopedPlugin: PluginCreator = (id = '') => { const keyframes = Object.create(null) const shortId = id.replace(/^data-v-/, '') return { postcssPlugin: 'vue-sfc-scoped', Rule(rule) { processRule(id, rule) }, AtRule(node) { if ( /-?keyframes$/.test(node.name) && !node.params.endsWith(`-${shortId}`) ) { // register keyframes keyframes[node.params] = node.params = node.params + '-' + shortId } }, OnceExit(root) { if (Object.keys(keyframes).length) { // If keyframes are found in this