element-plus/build/plugins/element-plus-alias.ts
三咲智子 f868d9afa3
feat(build): add full bundle locale (#5399)
* feat: add full bundle locale

* refactor: build
2022-01-17 11:19:11 +08:00

23 lines
582 B
TypeScript

import { EP_PKG, EP_PREFIX } from '../utils/constants'
import type { Plugin } from 'rollup'
export function ElementPlusAlias(): Plugin {
const THEME_CHALK = `${EP_PREFIX}/theme-chalk`
return {
name: 'element-plus-alias-plugin',
resolveId(id, importer, options) {
if (!id.startsWith(EP_PREFIX)) return
if (id.startsWith(THEME_CHALK)) {
return {
id: id.replaceAll(THEME_CHALK, `${EP_PKG}/theme-chalk`),
external: 'absolute',
}
}
return this.resolve(id, importer, { skipSelf: true, ...options })
},
}
}