forked from element-plus/element-plus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build(tokens): fix token build script (element-plus#3703)
- Loading branch information
Showing
5 changed files
with
43 additions
and
64 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,57 +1,46 @@ | ||
import path from 'path' | ||
import gulp from 'gulp' | ||
import { src, dest, parallel, series } from 'gulp' | ||
import ts from 'gulp-typescript' | ||
import { buildOutput } from '../../build/utils/paths' | ||
import { epOutput, projRoot } from '../../build/utils/paths' | ||
import rewriter from '../../build/gulp-rewriter' | ||
|
||
export const esm = './es' | ||
export const cjs = './lib' | ||
const tsProject = ts.createProject('tsconfig.json') | ||
|
||
const inputs = [ | ||
'./*.ts', | ||
'!./node_modules', | ||
'!./gulpfile.ts', | ||
'!./__tests__/*.ts', | ||
] | ||
|
||
function compileEsm() { | ||
return gulp | ||
.src(inputs) | ||
.pipe(tsProject()) | ||
.pipe(rewriter('..')) | ||
.pipe(gulp.dest(esm)) | ||
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))) | ||
) | ||
} | ||
|
||
function compileCjs() { | ||
return gulp | ||
.src(inputs) | ||
.pipe( | ||
ts.createProject('tsconfig.json', { | ||
module: 'commonjs', | ||
})() | ||
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')) | ||
) | ||
.pipe(rewriter('..')) | ||
.pipe(gulp.dest(cjs)) | ||
}) | ||
} | ||
|
||
const distBundle = path.resolve(buildOutput, './element-plus') | ||
|
||
/** | ||
* copy from packages/hooks/lib to dist/hooks | ||
*/ | ||
function copyEsm() { | ||
return gulp | ||
.src(`${esm}/**`) | ||
.pipe(gulp.dest(path.resolve(distBundle, './es/tokens'))) | ||
} | ||
|
||
function copyCjs() { | ||
return gulp | ||
.src(`${cjs}/**`) | ||
.pipe(gulp.dest(path.resolve(distBundle, './lib/tokens'))) | ||
} | ||
|
||
export const build = gulp.series(compileEsm, compileCjs, copyEsm, copyCjs) | ||
|
||
export default build | ||
export default parallel( | ||
series(buildTokens('cjs'), copyTokens('cjs')), | ||
series(buildTokens('esm'), copyTokens('esm')) | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
/* eslint-disable */ | ||
declare module '*.vue' { | ||
import { DefineComponent } from 'vue' | ||
import type { DefineComponent } from 'vue' | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
const component: DefineComponent<{}, {}, any> | ||
export default component | ||
} |