build: 修改 rollup 配置
parent
fb4762d01a
commit
fd07afa0a0
|
@ -31,24 +31,29 @@ function buildConfig(format: ModuleFormat | 'dts'): RollupOptions {
|
|||
sourcemap: isDts ? false : sourceMap,
|
||||
};
|
||||
|
||||
return {
|
||||
input: inputPath,
|
||||
output,
|
||||
plugins: [
|
||||
isDts
|
||||
? [
|
||||
const plugins: Plugin[] = [];
|
||||
if (isDts) {
|
||||
plugins.push(
|
||||
dtsPlugin({
|
||||
tsconfig: resolve('tsconfig.json'),
|
||||
}),
|
||||
compleTypePlugin([resolve('global.d.ts')]),
|
||||
]
|
||||
: esbuildPlugin({
|
||||
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,
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -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(
|
||||
|
|
|
@ -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');
|
||||
|
|
Loading…
Reference in New Issue