|
1 | 1 | import * as path from 'node:path'; |
2 | | -import { pluginCallstackTheme } from '@callstack/rspress-theme/plugin'; |
3 | | -import { pluginLlms } from '@rspress/plugin-llms'; |
4 | | -import { pluginOpenGraph } from 'rsbuild-plugin-open-graph'; |
5 | | -import pluginSitemap from 'rspress-plugin-sitemap'; |
6 | | -import vercelAnalytics from 'rspress-plugin-vercel-analytics'; |
7 | | -import { defineConfig } from 'rspress/config'; |
| 2 | +import { withCallstackPreset } from '@callstack/rspress-preset'; |
8 | 3 |
|
9 | 4 | const LATEST_VERSION = 'v5'; |
10 | 5 |
|
11 | 6 | const DOCS_ROOT = path.join('src', process.env.REPACK_DOC_VERSION ?? 'latest'); |
12 | 7 | const EDIT_ROOT_URL = `https://github.com/callstack/repack/tree/main/website/${DOCS_ROOT}`; |
13 | 8 |
|
14 | | -export default defineConfig({ |
15 | | - root: path.join(__dirname, DOCS_ROOT), |
16 | | - outDir: 'build', |
17 | | - title: process.env.REPACK_DOC_VERSION |
18 | | - ? `[${process.env.REPACK_DOC_VERSION}] Re.Pack` |
19 | | - : 'Re.Pack', |
20 | | - description: |
21 | | - 'A modern build tool for React Native that brings the Rspack and webpack ecosystem to mobile React Native apps', |
22 | | - icon: '/img/favicon.ico', |
23 | | - logo: { |
24 | | - light: '/img/logo-light.png', |
25 | | - dark: '/img/logo-dark.png', |
26 | | - }, |
27 | | - markdown: { |
28 | | - checkDeadLinks: true, |
29 | | - }, |
30 | | - route: { |
31 | | - cleanUrls: true, |
32 | | - }, |
33 | | - search: { |
34 | | - versioned: true, |
35 | | - codeBlocks: true, |
36 | | - }, |
37 | | - themeConfig: { |
38 | | - enableContentAnimation: true, |
39 | | - enableScrollToTop: true, |
40 | | - outlineTitle: 'Contents', |
41 | | - footer: { |
42 | | - message: `Copyright © ${new Date().getFullYear()} Callstack Open Source`, |
43 | | - }, |
44 | | - editLink: { |
45 | | - docRepoBaseUrl: EDIT_ROOT_URL, |
46 | | - text: 'Edit this page on GitHub', |
47 | | - }, |
48 | | - socialLinks: [ |
49 | | - { |
50 | | - icon: 'github', |
51 | | - mode: 'link', |
52 | | - content: 'https://github.com/callstack/repack', |
53 | | - }, |
54 | | - { |
55 | | - icon: 'X', |
56 | | - mode: 'link', |
57 | | - content: 'https://x.com/repack_rn', |
| 9 | +export default withCallstackPreset( |
| 10 | + { |
| 11 | + context: __dirname, |
| 12 | + docs: { |
| 13 | + description: |
| 14 | + 'A modern build tool for React Native that brings the Rspack and webpack ecosystem to mobile React Native apps', |
| 15 | + editUrl: EDIT_ROOT_URL, |
| 16 | + icon: '/img/favicon.ico', |
| 17 | + logoDark: '/img/logo-dark.png', |
| 18 | + logoLight: '/img/logo-light.png', |
| 19 | + ogImage: '/img/og-image.jpg', |
| 20 | + rootDir: DOCS_ROOT, |
| 21 | + rootUrl: 'https://re-pack.dev', |
| 22 | + socials: { |
| 23 | + github: 'https://github.com/callstack/repack', |
| 24 | + x: 'https://x.com/repack_rn', |
| 25 | + discord: 'https://discord.gg/TWDBep3nXV', |
58 | 26 | }, |
59 | | - { |
60 | | - icon: 'discord', |
61 | | - mode: 'link', |
62 | | - content: 'https://discord.gg/TWDBep3nXV', |
63 | | - }, |
64 | | - ], |
| 27 | + title: process.env.REPACK_DOC_VERSION |
| 28 | + ? `[${process.env.REPACK_DOC_VERSION}] Re.Pack` |
| 29 | + : 'Re.Pack', |
| 30 | + }, |
65 | 31 | }, |
66 | | - builderConfig: { |
67 | | - source: { |
68 | | - define: { |
69 | | - 'global.__REPACK_DOC_VERSION__': JSON.stringify( |
70 | | - process.env.REPACK_DOC_VERSION |
71 | | - ), |
72 | | - 'global.__REPACK_DOC_LATEST_VERSION__': JSON.stringify(LATEST_VERSION), |
73 | | - }, |
| 32 | + { |
| 33 | + outDir: 'build', |
| 34 | + globalStyles: |
| 35 | + process.env.REPACK_DOC_VERSION !== 'v2' && |
| 36 | + process.env.REPACK_DOC_VERSION !== 'v3' && |
| 37 | + process.env.REPACK_DOC_VERSION !== 'v4' |
| 38 | + ? path.join(__dirname, 'theme', 'styles.css') |
| 39 | + : undefined, |
| 40 | + themeConfig: { |
| 41 | + enableScrollToTop: true, |
74 | 42 | }, |
75 | | - output: { |
76 | | - distPath: { |
77 | | - // set explicitly for sitemap plugin |
78 | | - root: 'build', |
| 43 | + builderConfig: { |
| 44 | + source: { |
| 45 | + define: { |
| 46 | + 'global.__REPACK_DOC_VERSION__': JSON.stringify( |
| 47 | + process.env.REPACK_DOC_VERSION |
| 48 | + ), |
| 49 | + 'global.__REPACK_DOC_LATEST_VERSION__': |
| 50 | + JSON.stringify(LATEST_VERSION), |
| 51 | + }, |
79 | 52 | }, |
80 | | - }, |
81 | | - plugins: [ |
82 | | - pluginOpenGraph({ |
83 | | - title: 'Re.Pack', |
84 | | - type: 'website', |
85 | | - url: 'https://re-pack.dev', |
86 | | - image: 'https://re-pack.dev/img/og-image.jpg', |
87 | | - description: 'A modern build tool for React Native', |
88 | | - twitter: { |
89 | | - site: '@repack_rn', |
90 | | - card: 'summary_large_image', |
| 53 | + tools: { |
| 54 | + rspack(_config, { addRules }) { |
| 55 | + addRules([ |
| 56 | + { |
| 57 | + resourceQuery: /raw/, |
| 58 | + type: 'asset/source', |
| 59 | + }, |
| 60 | + ]); |
91 | 61 | }, |
92 | | - }), |
93 | | - ], |
94 | | - tools: { |
95 | | - rspack(_config, { addRules }) { |
96 | | - addRules([ |
97 | | - { |
98 | | - resourceQuery: /raw/, |
99 | | - type: 'asset/source', |
100 | | - }, |
101 | | - ]); |
102 | 62 | }, |
103 | 63 | }, |
104 | | - }, |
105 | | - globalStyles: |
106 | | - process.env.REPACK_DOC_VERSION !== 'v2' && |
107 | | - process.env.REPACK_DOC_VERSION !== 'v3' && |
108 | | - process.env.REPACK_DOC_VERSION !== 'v4' |
109 | | - ? path.join(__dirname, 'theme', 'styles.css') |
110 | | - : undefined, |
111 | | - plugins: [ |
112 | | - // @ts-ignore |
113 | | - pluginSitemap({ |
114 | | - domain: 'https://re-pack.dev', |
115 | | - }), |
116 | | - // @ts-ignore |
117 | | - vercelAnalytics(), |
118 | | - // @ts-ignore |
119 | | - pluginCallstackTheme(), |
120 | | - pluginLlms({ |
121 | | - exclude: ({ page }) => { |
122 | | - return page.routePath.includes('404'); |
123 | | - }, |
124 | | - }), |
125 | | - ], |
126 | | -}); |
| 64 | + } |
| 65 | +); |
0 commit comments