element-plus/internal/build/gulpfile.ts

67 lines
1.8 KiB
TypeScript
Raw Normal View History

import path from 'path'
import { copyFile, mkdir } from 'fs/promises'
import { copy } from 'fs-extra'
import { parallel, series } from 'gulp'
import {
buildOutput,
epOutput,
epPackage,
projRoot,
} from '@element-plus/build-utils'
import { buildConfig, run, runTask, withTaskName } from './src'
import type { TaskFunction } from 'gulp'
import type { Module } from './src'
2021-12-10 23:48:21 +08:00
export const copyFiles = () =>
Promise.all([
copyFile(epPackage, path.join(epOutput, 'package.json')),
copyFile(
2021-12-10 23:48:21 +08:00
path.resolve(projRoot, 'README.md'),
path.resolve(epOutput, 'README.md')
),
2021-12-10 23:48:21 +08:00
copyFile(
path.resolve(projRoot, 'typings', 'global.d.ts'),
2021-12-10 23:48:21 +08:00
path.resolve(epOutput, 'global.d.ts')
),
])
export const copyTypesDefinitions: TaskFunction = (done) => {
2022-06-05 12:14:08 +08:00
const src = path.resolve(buildOutput, 'types', 'packages')
const copyTypes = (module: Module) =>
withTaskName(`copyTypes:${module}`, () =>
copy(src, buildConfig[module].output.path, { recursive: true })
)
return parallel(copyTypes('esm'), copyTypes('cjs'))(done)
}
export const copyFullStyle = async () => {
await mkdir(path.resolve(epOutput, 'dist'), { recursive: true })
await copyFile(
path.resolve(epOutput, 'theme-chalk/index.css'),
path.resolve(epOutput, 'dist/index.css')
)
}
2021-09-26 01:29:07 +08:00
export default series(
withTaskName('clean', () => run('pnpm run clean')),
withTaskName('createOutput', () => mkdir(epOutput, { recursive: true })),
2021-09-26 01:29:07 +08:00
parallel(
runTask('buildModules'),
2021-09-26 01:29:07 +08:00
runTask('buildFullBundle'),
runTask('generateTypesDefinitions'),
2021-09-26 01:29:07 +08:00
runTask('buildHelper'),
series(
withTaskName('buildThemeChalk', () =>
2022-05-02 14:51:59 +08:00
run('pnpm run -C packages/theme-chalk build')
),
copyFullStyle
2021-09-26 01:29:07 +08:00
)
),
parallel(copyTypesDefinitions, copyFiles)
2021-09-26 01:29:07 +08:00
)
export * from './src'