2021-09-17 15:27:31 +08:00
|
|
|
import path from 'path'
|
2021-08-24 13:36:48 +08:00
|
|
|
import gulp from 'gulp'
|
|
|
|
import ts from 'gulp-typescript'
|
2021-09-26 01:29:07 +08:00
|
|
|
import { buildOutput } from '../../build/utils/paths'
|
2021-08-24 13:36:48 +08:00
|
|
|
|
2021-09-13 13:14:39 +08:00
|
|
|
import type { Settings } from 'gulp-typescript'
|
|
|
|
|
2021-08-24 13:36:48 +08:00
|
|
|
export const esm = './es'
|
|
|
|
export const cjs = './lib'
|
|
|
|
|
|
|
|
const inputs = ['./**/*.ts', '!gulpfile.ts', '!./node_modules', '!./tests/*.ts']
|
|
|
|
|
2021-09-13 13:14:39 +08:00
|
|
|
function createProject(settings: Settings = {}) {
|
|
|
|
return ts.createProject('tsconfig.json', {
|
|
|
|
// temporarily disabled
|
|
|
|
// TODO: remove this
|
|
|
|
strict: false,
|
|
|
|
...settings,
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2021-08-24 13:36:48 +08:00
|
|
|
function compileEsm() {
|
2021-09-13 13:14:39 +08:00
|
|
|
return gulp.src(inputs).pipe(createProject()()).pipe(gulp.dest(esm))
|
2021-08-24 13:36:48 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function compileCjs() {
|
|
|
|
return gulp
|
|
|
|
.src(inputs)
|
2021-09-13 13:14:39 +08:00
|
|
|
.pipe(createProject({ module: 'commonjs' })())
|
2021-08-24 13:36:48 +08:00
|
|
|
.pipe(gulp.dest(cjs))
|
|
|
|
}
|
|
|
|
|
|
|
|
const distBundle = path.resolve(buildOutput, './element-plus')
|
|
|
|
|
|
|
|
/**
|
|
|
|
* copy from packages/theme-chalk/lib to dist/theme-chalk
|
|
|
|
*/
|
|
|
|
function copyEsm() {
|
|
|
|
return gulp
|
2021-09-17 09:18:24 +08:00
|
|
|
.src(`${cjs}/**`)
|
2021-08-24 13:36:48 +08:00
|
|
|
.pipe(gulp.dest(path.resolve(distBundle, './lib/utils')))
|
|
|
|
}
|
|
|
|
|
|
|
|
function copyCjs() {
|
|
|
|
return gulp
|
2021-09-17 09:18:24 +08:00
|
|
|
.src(`${esm}/**`)
|
2021-08-24 13:36:48 +08:00
|
|
|
.pipe(gulp.dest(path.resolve(distBundle, './es/utils')))
|
|
|
|
}
|
|
|
|
|
|
|
|
export const build = gulp.series(compileEsm, compileCjs, copyEsm, copyCjs)
|
|
|
|
|
|
|
|
export default build
|