rspress.config.ts 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. import * as path from 'node:path';
  2. import { merge } from 'webpack-merge';
  3. import { defineConfig } from 'rspress/config';
  4. export default defineConfig({
  5. root: path.join(__dirname, 'src'),
  6. base: '/',
  7. title: 'FlowGram.AI',
  8. globalStyles: path.join(__dirname, './global.less'),
  9. builderConfig: {
  10. source: {
  11. decorators: {
  12. version: 'legacy',
  13. },
  14. },
  15. tools: {
  16. rspack(options) {
  17. return merge(options, {
  18. module: {
  19. rules: [
  20. {
  21. test: /\.mdc$/,
  22. type: 'asset/source',
  23. },
  24. {
  25. resourceQuery: /raw/,
  26. type: 'asset/source',
  27. },
  28. ],
  29. },
  30. optimization: {
  31. splitChunks: {
  32. chunks: 'all', // 拆分所有模块,包括异步和同步
  33. minSize: 30 * 1024, // 30KB 以下不拆分
  34. maxSize: 500 * 1024, // 500KB 以上强制拆分
  35. minChunks: 1, // 最少被引用 1 次就可以拆分
  36. automaticNameDelimiter: '-',
  37. cacheGroups: {
  38. vendors: {
  39. test: /[\\/]node_modules[\\/]/,
  40. name: 'vendors',
  41. chunks: 'all',
  42. priority: -10, // 优先级
  43. },
  44. },
  45. },
  46. },
  47. // 禁用 ES 模块输出(启用 CommonJS)
  48. experiments: {
  49. outputModule: false,
  50. },
  51. // 允许省略文件扩展名
  52. resolve: {
  53. fullySpecified: false,
  54. },
  55. });
  56. },
  57. },
  58. },
  59. ssg: false,
  60. // locales 为一个对象数组
  61. locales: [
  62. {
  63. lang: 'en',
  64. // 导航栏切换语言的标签
  65. label: 'English',
  66. title: 'Rspress',
  67. description: 'Static Site Generator',
  68. },
  69. {
  70. lang: 'zh',
  71. label: '简体中文',
  72. title: 'Rspress',
  73. description: '静态网站生成器',
  74. },
  75. ],
  76. icon: '/logo.png',
  77. logo: {
  78. light: '/logo.png',
  79. dark: '/logo.png',
  80. },
  81. lang: 'zh',
  82. logoText: 'FlowGram.AI',
  83. plugins: [],
  84. themeConfig: {
  85. localeRedirect: 'auto',
  86. footer: {
  87. message: '© 2025 Bytedance Inc. All Rights Reserved.',
  88. },
  89. lastUpdated: true,
  90. locales: [
  91. {
  92. lang: 'en',
  93. label: 'en',
  94. outlineTitle: 'ON THIS Page',
  95. },
  96. {
  97. lang: 'zh',
  98. label: 'zh',
  99. outlineTitle: '大纲',
  100. searchNoResultsText: '未搜索到相关结果',
  101. searchPlaceholderText: '搜索文档',
  102. searchSuggestedQueryText: '可更换不同的关键字后重试',
  103. overview: {
  104. filterNameText: '过滤',
  105. filterPlaceholderText: '输入关键词',
  106. filterNoResultText: '未找到匹配的 API',
  107. },
  108. },
  109. ],
  110. socialLinks: [
  111. {
  112. icon: 'github',
  113. mode: 'link',
  114. content: 'https://github.com/bytedance/flowgram.ai',
  115. },
  116. {
  117. icon: 'discord',
  118. mode: 'link',
  119. content: 'https://discord.gg/SwDWdrgA9f',
  120. },
  121. {
  122. icon: 'X',
  123. mode: 'link',
  124. content: 'https://x.com/FlowGramAI',
  125. },
  126. ],
  127. },
  128. });