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