rslib.config.ts 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. /**
  2. * Copyright (c) 2025 Bytedance Ltd. and/or its affiliates
  3. * SPDX-License-Identifier: MIT
  4. */
  5. import path from 'path';
  6. import { defineConfig } from '@rslib/core';
  7. type RsbuildConfig = Parameters<typeof defineConfig>[0];
  8. const commonConfig: Partial<RsbuildConfig> = {
  9. source: {
  10. entry: {
  11. index: ['./src/**/*.{ts,tsx}'],
  12. },
  13. exclude: [],
  14. decorators: {
  15. version: 'legacy',
  16. },
  17. },
  18. bundle: false,
  19. dts: {
  20. distPath: path.resolve(__dirname, './dist/types'),
  21. bundle: false,
  22. build: true,
  23. },
  24. tools: {},
  25. };
  26. const formats: Partial<RsbuildConfig>[] = [
  27. {
  28. format: 'esm',
  29. output: {
  30. distPath: {
  31. root: path.resolve(__dirname, './dist/esm'),
  32. },
  33. },
  34. },
  35. {
  36. dts: false,
  37. format: 'cjs',
  38. output: {
  39. distPath: {
  40. root: path.resolve(__dirname, './dist/cjs'),
  41. },
  42. },
  43. },
  44. ].map((r) => ({ ...commonConfig, ...r }));
  45. export default defineConfig({
  46. lib: formats,
  47. output: {
  48. cleanDistPath: process.env.NODE_ENV === 'production',
  49. },
  50. });