gulpfile.ts 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. import path from 'path'
  2. import { copyFile, mkdir } from 'fs/promises'
  3. import { copy } from 'fs-extra'
  4. import { parallel, series } from 'gulp'
  5. import {
  6. buildOutput,
  7. epOutput,
  8. epPackage,
  9. projRoot,
  10. } from '@element-plus/build-utils'
  11. import { buildConfig, run, runTask, withTaskName } from './src'
  12. import type { TaskFunction } from 'gulp'
  13. import type { Module } from './src'
  14. export const copyFiles = () =>
  15. Promise.all([
  16. copyFile(epPackage, path.join(epOutput, 'package.json')),
  17. copyFile(
  18. path.resolve(projRoot, 'README.md'),
  19. path.resolve(epOutput, 'README.md')
  20. ),
  21. copyFile(
  22. path.resolve(projRoot, 'global.d.ts'),
  23. path.resolve(epOutput, 'global.d.ts')
  24. ),
  25. ])
  26. export const copyTypesDefinitions: TaskFunction = (done) => {
  27. const src = path.resolve(buildOutput, 'types', 'packages')
  28. const copyTypes = (module: Module) =>
  29. withTaskName(`copyTypes:${module}`, () =>
  30. copy(src, buildConfig[module].output.path, { recursive: true })
  31. )
  32. return parallel(copyTypes('esm'), copyTypes('cjs'))(done)
  33. }
  34. export const copyFullStyle = async () => {
  35. await mkdir(path.resolve(epOutput, 'dist'), { recursive: true })
  36. await copyFile(
  37. path.resolve(epOutput, 'theme-chalk/index.css'),
  38. path.resolve(epOutput, 'dist/index.css')
  39. )
  40. }
  41. export default series(
  42. withTaskName('clean', () => run('pnpm run clean')),
  43. withTaskName('createOutput', () => mkdir(epOutput, { recursive: true })),
  44. parallel(
  45. runTask('buildModules'),
  46. runTask('buildFullBundle'),
  47. runTask('generateTypesDefinitions'),
  48. runTask('buildHelper'),
  49. series(
  50. withTaskName('buildThemeChalk', () =>
  51. run('pnpm run -C packages/theme-chalk build')
  52. ),
  53. copyFullStyle
  54. )
  55. ),
  56. parallel(copyTypesDefinitions, copyFiles)
  57. )
  58. export * from './src'