2021-09-17 15:27:31 +08:00
|
|
|
import path from 'path'
|
2021-09-28 15:40:08 +08:00
|
|
|
import { src, dest, parallel, series } from 'gulp'
|
2021-08-24 13:36:48 +08:00
|
|
|
import ts from 'gulp-typescript'
|
2021-09-28 15:40:08 +08:00
|
|
|
import { epOutput, projRoot } from '../../build/utils/paths'
|
2021-08-24 13:36:48 +08:00
|
|
|
import rewriter from '../../build/gulp-rewriter'
|
2021-09-28 15:40:08 +08:00
|
|
|
import { buildConfig } from '../../build/info'
|
|
|
|
import { withTaskName } from '../../build/utils/gulp'
|
|
|
|
|
|
|
|
import type { Module } from '../../build/info'
|
|
|
|
|
|
|
|
export const buildTokens = (module: Module) => {
|
|
|
|
const tsConfig = path.resolve(projRoot, 'tsconfig.json')
|
|
|
|
const inputs = [
|
|
|
|
'./*.ts',
|
|
|
|
'!./node_modules',
|
|
|
|
'!./gulpfile.ts',
|
|
|
|
'!./__tests__/*.ts',
|
|
|
|
path.resolve(projRoot, 'typings', 'vue-shim.d.ts'),
|
|
|
|
]
|
|
|
|
const config = buildConfig[module]
|
|
|
|
return withTaskName(`buildTokens:${module}`, () =>
|
|
|
|
src(inputs)
|
|
|
|
.pipe(
|
|
|
|
ts.createProject(tsConfig, {
|
|
|
|
module: config.module,
|
|
|
|
strict: false,
|
|
|
|
})()
|
|
|
|
)
|
|
|
|
.pipe(rewriter('..'))
|
|
|
|
.pipe(dest(path.resolve(__dirname, config.output.name)))
|
|
|
|
)
|
2021-08-24 13:36:48 +08:00
|
|
|
}
|
|
|
|
|
2021-09-28 15:40:08 +08:00
|
|
|
const copyTokens = (module: Module) => {
|
|
|
|
const config = buildConfig[module]
|
|
|
|
return withTaskName(`copyTokens:${module}`, () => {
|
|
|
|
return src(`${path.resolve(__dirname, config.output.name)}/**`).pipe(
|
|
|
|
dest(path.resolve(epOutput, config.output.name, 'tokens'))
|
2021-08-24 13:36:48 +08:00
|
|
|
)
|
2021-09-28 15:40:08 +08:00
|
|
|
})
|
2021-08-24 13:36:48 +08:00
|
|
|
}
|
|
|
|
|
2021-09-28 15:40:08 +08:00
|
|
|
export default parallel(
|
|
|
|
series(buildTokens('cjs'), copyTokens('cjs')),
|
|
|
|
series(buildTokens('esm'), copyTokens('esm'))
|
|
|
|
)
|