From fd07afa0a0d923b8494bcfde09543c9854775e75 Mon Sep 17 00:00:00 2001 From: zjx0905 <954270063@qq.com> Date: Tue, 18 Apr 2023 10:16:35 +0800 Subject: [PATCH] =?UTF-8?q?build:=20=E4=BF=AE=E6=94=B9=20rollup=20?= =?UTF-8?q?=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- rollup.config.ts | 39 ++++++++++++++++++++++----------------- scripts/docs.deploy.ts | 4 ++-- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/rollup.config.ts b/rollup.config.ts index 6a6140c..ea5eb2d 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -31,24 +31,29 @@ function buildConfig(format: ModuleFormat | 'dts'): RollupOptions { sourcemap: isDts ? false : sourceMap, }; + const plugins: Plugin[] = []; + if (isDts) { + plugins.push( + dtsPlugin({ + tsconfig: resolve('tsconfig.json'), + }), + patchTypePlugin([resolve('global.d.ts')]), + ); + } else { + plugins.push( + esbuildPlugin({ + tsconfig: resolve('tsconfig.json'), + sourceMap: output.sourcemap as boolean, + target: 'es2015', + minify: true, + }), + ); + } + return { input: inputPath, output, - plugins: [ - isDts - ? [ - dtsPlugin({ - tsconfig: resolve('tsconfig.json'), - }), - compleTypePlugin([resolve('global.d.ts')]), - ] - : esbuildPlugin({ - tsconfig: resolve('tsconfig.json'), - sourceMap: output.sourcemap as boolean, - target: 'es2015', - minify: true, - }), - ], + plugins, }; } @@ -56,9 +61,9 @@ function resolveOutput(format: string, isDts?: boolean) { return resolve(distPath, `${pkg.name}${isDts ? '.d.ts' : `.${format}.js`}`); } -function compleTypePlugin(files: string[]): Plugin { +function patchTypePlugin(files: string[]): Plugin { return { - name: 'comple-type', + name: 'patch-type', renderChunk: (code) => `${files .map( diff --git a/scripts/docs.deploy.ts b/scripts/docs.deploy.ts index 6e2c395..6f715c7 100644 --- a/scripts/docs.deploy.ts +++ b/scripts/docs.deploy.ts @@ -6,7 +6,7 @@ main(); function main() { exec('pnpm docs:build'); - console.log('\n'); + console.log(''); consola.info('Clean'); const exist = exec('git branch --list docs', { stdio: 'pipe', @@ -17,7 +17,7 @@ function main() { if (exist) { exec('git branch -D docs'); } - console.log('\n'); + console.log(''); consola.info('Create docs\n'); exec('git branch docs');