element-plus/build/rollup-plugin-entry.ts

24 lines
588 B
TypeScript
Raw Normal View History

import path from 'path'
import type { Plugin } from 'rollup'
2021-09-26 01:29:07 +08:00
export function RollupResolveEntryPlugin(): Plugin {
return {
name: 'element-plus-entry-plugin',
transform(code, id) {
if (id.includes('packages')) {
return {
code: code.replace(
/@element-plus\/(components|directives|utils|hooks|tokens|locale)/g,
`${path.relative(
path.dirname(id),
path.resolve(__dirname, '../packages')
)}/$1`
),
map: null,
}
}
return { code, map: null }
},
}
}