mirror of
https://github.com/element-plus/element-plus.git
synced 2026-03-13 07:51:17 +08:00
* build: refactor build * refactor: reorganize files * refactor: refactor build * build: improve perf * fix: scripts * build: add rollup-plugin-filesize * chore: scripts ignore no-console * build: disable tree-shaking * build: improve code * build: add sourcemap * build: add banner * refactor: remove annotation
33 lines
923 B
TypeScript
33 lines
923 B
TypeScript
import path from 'path'
|
|
import { pkgRoot } from '../utils/paths'
|
|
import { EP_PKG, EP_PREFIX } from '../utils/constants'
|
|
import { getWorkspaceNames } from '../utils/pkg'
|
|
import type { Plugin } from 'rollup'
|
|
|
|
export async function RollupResolveEntryPlugin(): Promise<Plugin> {
|
|
const pkgs = (await getWorkspaceNames(pkgRoot))
|
|
.filter((pkg) => pkg.startsWith(`${EP_PREFIX}/`))
|
|
.map((pkg) => pkg.replace(`${EP_PREFIX}/`, ''))
|
|
|
|
return {
|
|
name: 'element-plus-entry-plugin',
|
|
|
|
transform(code, id) {
|
|
if (id.includes('packages')) {
|
|
code = code.replaceAll(
|
|
`${EP_PREFIX}/theme-chalk`,
|
|
`${EP_PKG}/theme-chalk`
|
|
)
|
|
code = code.replace(
|
|
new RegExp(`@element-plus\\/(${pkgs.join('|')})`, 'g'),
|
|
`${path.relative(path.dirname(id), path.resolve(pkgRoot))}/$1`
|
|
)
|
|
return {
|
|
code,
|
|
map: null,
|
|
}
|
|
}
|
|
},
|
|
}
|
|
}
|