diff --git a/README.md b/README.md index 6c883b7f71faf..9883da01da0f5 100644 --- a/README.md +++ b/README.md @@ -144,7 +144,7 @@ $ pnpm gen component-name Note the `component-name` must be in `kebab-case`, combining words by replacing each space with a dash. -And component type must be added to `packages/element-plus/global.d.ts`. +And component type must be added to `typings/global.d.ts`. ## Commit template diff --git a/build/entry-types.ts b/build/entry-types.ts index af7d8e338a91e..27dcd3f5e3e56 100644 --- a/build/entry-types.ts +++ b/build/entry-types.ts @@ -74,20 +74,8 @@ export const genEntryTypes = async () => { export const copyEntryTypes = (() => { const src = path.resolve(buildOutput, 'entry/types') const copy = (module: Module) => - parallel( - withTaskName(`copyEntryTypes:${module}`, () => - run(`rsync -a ${src}/ ${buildConfig[module].output.path}/`) - ), - withTaskName('copyEntryDefinitions', async () => { - const files = await glob('*.d.ts', { - cwd: epRoot, - absolute: true, - onlyFiles: true, - }) - await run( - `rsync -a ${files.join(' ')} ${buildConfig[module].output.path}/` - ) - }) + withTaskName(`copyEntryTypes:${module}`, () => + run(`rsync -a ${src}/ ${buildConfig[module].output.path}/`) ) return parallel(copy('esm'), copy('cjs')) diff --git a/build/gulpfile.ts b/build/gulpfile.ts index 80ca22ecad3a2..0853b2991d947 100644 --- a/build/gulpfile.ts +++ b/build/gulpfile.ts @@ -1,22 +1,27 @@ +import path from 'path' import { series, parallel } from 'gulp' - import { copyStyle } from './style' import { copyEntryTypes } from './entry-types' import { run } from './utils/process' import { withTaskName } from './utils/gulp' -import { epOutput, buildOutput, epPackage } from './utils/paths' +import { epOutput, epPackage, projRoot } from './utils/paths' import { copyFullStyle } from './full-bundle' const runTask = (name: string) => withTaskName(name, () => run(`pnpm run build ${name}`)) -const copySourceCode = () => async () => { +export const copySourceCode = async () => { await run(`cp -R packages ${epOutput}`) await run(`cp ${epPackage} ${epOutput}/package.json`) } -const copyREADME = () => async () => { - await run(`cp README.md ${buildOutput}/element-plus`) +export const copyREADME = async () => { + await run(`cp README.md ${epOutput}`) +} + +export const copyDefinitions = async () => { + const files = [path.resolve(projRoot, 'typings', 'global.d.ts')] + await run(`cp ${files.join(' ')} ${epOutput}`) } export default series( @@ -36,8 +41,9 @@ export default series( copyStyle(), copyFullStyle, copyEntryTypes, - copySourceCode(), - copyREADME() + copySourceCode, + copyREADME, + copyDefinitions ) ) diff --git a/packages/element-plus/global.d.ts b/typings/global.d.ts similarity index 100% rename from packages/element-plus/global.d.ts rename to typings/global.d.ts