build: 修改 rollup 配置
parent
fb4762d01a
commit
fd07afa0a0
|
@ -31,24 +31,29 @@ function buildConfig(format: ModuleFormat | 'dts'): RollupOptions {
|
||||||
sourcemap: isDts ? false : sourceMap,
|
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 {
|
return {
|
||||||
input: inputPath,
|
input: inputPath,
|
||||||
output,
|
output,
|
||||||
plugins: [
|
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,
|
|
||||||
}),
|
|
||||||
],
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -56,9 +61,9 @@ function resolveOutput(format: string, isDts?: boolean) {
|
||||||
return resolve(distPath, `${pkg.name}${isDts ? '.d.ts' : `.${format}.js`}`);
|
return resolve(distPath, `${pkg.name}${isDts ? '.d.ts' : `.${format}.js`}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
function compleTypePlugin(files: string[]): Plugin {
|
function patchTypePlugin(files: string[]): Plugin {
|
||||||
return {
|
return {
|
||||||
name: 'comple-type',
|
name: 'patch-type',
|
||||||
renderChunk: (code) =>
|
renderChunk: (code) =>
|
||||||
`${files
|
`${files
|
||||||
.map(
|
.map(
|
||||||
|
|
|
@ -6,7 +6,7 @@ main();
|
||||||
function main() {
|
function main() {
|
||||||
exec('pnpm docs:build');
|
exec('pnpm docs:build');
|
||||||
|
|
||||||
console.log('\n');
|
console.log('');
|
||||||
consola.info('Clean');
|
consola.info('Clean');
|
||||||
const exist = exec('git branch --list docs', {
|
const exist = exec('git branch --list docs', {
|
||||||
stdio: 'pipe',
|
stdio: 'pipe',
|
||||||
|
@ -17,7 +17,7 @@ function main() {
|
||||||
if (exist) {
|
if (exist) {
|
||||||
exec('git branch -D docs');
|
exec('git branch -D docs');
|
||||||
}
|
}
|
||||||
console.log('\n');
|
console.log('');
|
||||||
|
|
||||||
consola.info('Create docs\n');
|
consola.info('Create docs\n');
|
||||||
exec('git branch docs');
|
exec('git branch docs');
|
||||||
|
|
Loading…
Reference in New Issue