rspress.config.ts 3.1 KB

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