gulpfile.ts 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 { buildOutput, epOutput, epPackage, projRoot } from '@kankan/build-utils'
  6. import { buildConfig, run, runTask, withTaskName } from './src'
  7. import type { TaskFunction } from 'gulp'
  8. import type { Module } from './src'
  9. export const copyFiles = () =>
  10. Promise.all([
  11. copyFile(epPackage, path.join(epOutput, 'package.json')),
  12. copyFile(path.resolve(projRoot, 'README.md'), path.resolve(epOutput, 'README.md')),
  13. copyFile(path.resolve(projRoot, 'global.d.ts'), path.resolve(epOutput, 'global.d.ts')),
  14. ])
  15. export const copyTypesDefinitions: TaskFunction = done => {
  16. const src = path.resolve(buildOutput, 'types', 'packages')
  17. const copyTypes = (module: Module) => withTaskName(`copyTypes:${module}`, () => copy(src, buildConfig[module].output.path, { recursive: true }))
  18. return parallel(copyTypes('esm'), copyTypes('cjs'))(done)
  19. }
  20. export const copyFullStyle = async () => {
  21. await mkdir(path.resolve(epOutput, 'dist'), { recursive: true })
  22. await copyFile(path.resolve(epOutput, 'theme-chalk/index.css'), path.resolve(epOutput, 'dist/index.css'))
  23. }
  24. export default series(
  25. withTaskName('clean', () => run('pnpm run clean')),
  26. withTaskName('createOutput', () => mkdir(epOutput, { recursive: true })),
  27. parallel(
  28. runTask('buildModules'),
  29. runTask('buildFullBundle'),
  30. runTask('generateTypesDefinitions'),
  31. runTask('buildHelper'),
  32. series(
  33. withTaskName('buildThemeChalk', () => run('pnpm run -C packages/theme-chalk build')),
  34. copyFullStyle
  35. )
  36. ),
  37. parallel(copyTypesDefinitions, copyFiles)
  38. )
  39. export * from './src'