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