rslib.config.ts 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. import { pluginReact } from '@rsbuild/plugin-react';
  8. type RsbuildConfig = Parameters<typeof defineConfig>[0];
  9. const commonConfig: Partial<RsbuildConfig> = {
  10. source: {
  11. entry: {
  12. index: ['./src/**/*.{ts,tsx,css}'],
  13. },
  14. exclude: [],
  15. decorators: {
  16. version: 'legacy',
  17. },
  18. },
  19. bundle: false,
  20. dts: {
  21. distPath: path.resolve(__dirname, './dist/types'),
  22. bundle: false,
  23. build: true,
  24. },
  25. tools: {},
  26. };
  27. const formats: Partial<RsbuildConfig>[] = [
  28. {
  29. format: 'esm',
  30. output: {
  31. distPath: {
  32. root: path.resolve(__dirname, './dist/esm'),
  33. },
  34. },
  35. },
  36. {
  37. dts: false,
  38. format: 'cjs',
  39. output: {
  40. distPath: {
  41. root: path.resolve(__dirname, './dist/cjs'),
  42. },
  43. },
  44. },
  45. ].map((r) => ({ ...commonConfig, ...r }));
  46. export default defineConfig({
  47. lib: formats,
  48. output: {
  49. target: 'web',
  50. cleanDistPath: process.env.NODE_ENV === 'production',
  51. },
  52. plugins: [pluginReact({ swcReactOptions: {} })],
  53. });