element-plus/build/style.ts

45 lines
1.3 KiB
TypeScript
Raw Normal View History

2021-09-26 01:29:07 +08:00
import path from 'path'
import { parallel, dest, src } from 'gulp'
import ts from 'gulp-typescript'
import { buildOutput, compRoot } from './utils/paths'
import { buildConfig } from './info'
import { withTaskName, gulpPathRewriter } from './utils/gulp'
2021-09-26 01:29:07 +08:00
import { run } from './utils/process'
import type { Module } from './info'
const inputs = path.resolve(compRoot, '**/style/*.ts')
const output = path.resolve(buildOutput, 'styles')
const tsProject = (module: Module) =>
ts.createProject('tsconfig.json', {
declaration: true,
target: 'ESNext',
skipLibCheck: true,
module: buildConfig[module].module,
})()
const build = (module: Module) =>
withTaskName(`buildStyle:${module}`, () =>
src(inputs)
.pipe(gulpPathRewriter(module))
2021-09-26 01:29:07 +08:00
.pipe(tsProject(module))
.pipe(dest(path.resolve(output, buildConfig[module].output.name)))
)
export const buildStyle = parallel(build('esm'), build('cjs'))
export const copyStyle = () => {
const copy = (module: Module) => {
const config = buildConfig[module]
const src = path.resolve(buildOutput, 'styles', config.output.name)
const dst = path.resolve(config.output.path, 'components')
return withTaskName(`copyStyle:${module}`, () =>
run(`rsync -a ${src}/ ${dst}/`)
)
}
return parallel(copy('esm'), copy('cjs'))
}