@plone/aurora 1.0.0-alpha.27 → 1.0.0-alpha.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/catalog.json +73 -0
  2. package/dist/preset.d.ts +25 -0
  3. package/dist/preset.js +14 -0
  4. package/dist/registry-publicui.config.d.ts +8 -0
  5. package/dist/registry-publicui.config.js +14 -0
  6. package/dist/registry.config.d.ts +16 -0
  7. package/dist/registry.config.js +17 -0
  8. package/dist/routes.d.ts +25 -0
  9. package/dist/routes.js +23 -0
  10. package/dist/vite.d.ts +24 -0
  11. package/dist/vite.js +135 -0
  12. package/package.json +93 -47
  13. package/pnpmfile.cjs +20 -0
  14. package/server.js +2 -1
  15. package/{app → src/app}/config/index.ts +1 -2
  16. package/{app → src/app}/config/server.server.ts +2 -4
  17. package/{app → src/app}/entry.client.tsx +1 -0
  18. package/{app → src/app}/entry.server.tsx +2 -1
  19. package/{app → src/app}/i18next.server.test.ts +48 -1
  20. package/{app → src/app}/i18next.server.ts +22 -14
  21. package/{app → src/app}/middleware.server.test.ts +0 -68
  22. package/{app → src/app}/middleware.server.ts +32 -40
  23. package/src/app/root.server.ts +124 -0
  24. package/{app → src/app}/root.test.tsx +36 -7
  25. package/src/app/root.tsx +101 -0
  26. package/.release-it.json +0 -32
  27. package/.stylelintrc +0 -8
  28. package/CHANGELOG.md +0 -456
  29. package/Makefile +0 -82
  30. package/acceptance/tests/anonymous-401-redirect.test.ts +0 -75
  31. package/acceptance/tests/basic.test.ts +0 -14
  32. package/acceptance/tests/hydration.test.ts +0 -106
  33. package/acceptance/tests/multilingual-root-redirect.test.ts +0 -45
  34. package/app/root.tsx +0 -191
  35. package/app/routes.ts +0 -20
  36. package/news/.gitkeep +0 -0
  37. package/public/favicon.ico +0 -0
  38. package/public/icon.svg +0 -13
  39. package/react-router.config.ts +0 -11
  40. package/registry-publicui.config.ts +0 -11
  41. package/registry.config.ts +0 -16
  42. package/tests/setup.ts +0 -6
  43. package/tests/testHelpers.tsx +0 -29
  44. package/towncrier.toml +0 -33
  45. package/tsconfig.json +0 -35
  46. package/vite.config.ts +0 -120
  47. package/vitest.config.ts +0 -32
  48. /package/{app → src/app}/config/index.test.ts +0 -0
  49. /package/{app → src/app}/config/server/content-migrations.server.test.ts +0 -0
  50. /package/{app → src/app}/config/server/content-migrations.server.ts +0 -0
  51. /package/{app → src/app}/config/server/migrations.server.ts +0 -0
  52. /package/{app → src/app}/config/server.server.test.ts +0 -0
  53. /package/{app → src/app}/config/types.ts +0 -0
  54. /package/{app → src/app}/i18n.ts +0 -0
  55. /package/{app → src/app}/okroute.test.tsx +0 -0
  56. /package/{app → src/app}/okroute.tsx +0 -0
  57. /package/{app → src/app}/reset-fetcher.test.tsx +0 -0
  58. /package/{app → src/app}/reset-fetcher.tsx +0 -0
@@ -1,106 +0,0 @@
1
- import { expect, test } from '../../../../packages/tooling/playwright/test';
2
- import type { Page } from '@playwright/test';
3
- import { PLONE_BLOCK_TYPE } from '@plone/helpers';
4
- import { createContent } from '../../../../packages/tooling/playwright/content';
5
-
6
- // If the server and client renders differ, React discards the server-rendered
7
- // DOM on hydration and renders it again on the client. Any element a test (or
8
- // script) grabbed before that is then detached and measures 0x0.
9
-
10
- const PAGE_ID = 'hydration-page';
11
- const IMAGE_ID = 'hydration-image';
12
-
13
- async function setupImageBlockPage(page: Page) {
14
- await createContent(page, {
15
- contentType: 'Image',
16
- contentId: IMAGE_ID,
17
- contentTitle: 'Hydration image',
18
- image: {
19
- sourceFilename: 'halfdome2022.jpg',
20
- filename: 'halfdome2022.jpg',
21
- 'content-type': 'image/jpeg',
22
- },
23
- });
24
- await createContent(page, {
25
- contentType: 'Document',
26
- contentId: PAGE_ID,
27
- contentTitle: 'Hydration page',
28
- transition: 'publish',
29
- bodyModifier: (body) => ({
30
- ...body,
31
- blocks: {
32
- main: {
33
- '@type': 'plate',
34
- value: [
35
- { type: 'title', children: [{ text: 'Hydration page' }] },
36
- { type: 'p', children: [{ text: 'Text before image' }] },
37
- {
38
- type: PLONE_BLOCK_TYPE,
39
- '@type': 'image',
40
- url: `/${IMAGE_ID}`,
41
- align: 'left',
42
- size: 'l',
43
- blockWidth: 'default',
44
- children: [{ text: '' }],
45
- },
46
- { type: 'p', children: [{ text: 'Text after image' }] },
47
- ],
48
- },
49
- },
50
- }),
51
- });
52
- }
53
-
54
- test.describe('Hydration', () => {
55
- test('the server renders translated messages', async ({ page }) => {
56
- const html = await (await page.request.get('/')).text();
57
- expect(
58
- html.includes('layout.slots.headertools.anonymousTools.login'),
59
- 'the server rendered a raw message key',
60
- ).toBe(false);
61
- expect(html.includes('>Log In<'), 'the server rendered "Log In"').toBe(
62
- true,
63
- );
64
- });
65
-
66
- test('the server-rendered image block survives hydration', async ({
67
- page,
68
- }) => {
69
- await setupImageBlockPage(page);
70
-
71
- // Keep a reference to the server-rendered node, before React hydrates.
72
- await page.addInitScript(() => {
73
- document.addEventListener('DOMContentLoaded', () => {
74
- (window as any).__ssrImageBlock = document.querySelector(
75
- '.block-image__frame',
76
- );
77
- });
78
- });
79
- await page.goto(`/${PAGE_ID}`);
80
-
81
- // Wait until React owns the current `.block-image__frame`, i.e. hydration (or a
82
- // client re-render after a failed hydration) has finished.
83
- await expect
84
- .poll(() =>
85
- page.evaluate(() => {
86
- const el = document.querySelector('.block-image__frame');
87
- return (
88
- !!el && Object.keys(el).some((k) => k.startsWith('__reactFiber'))
89
- );
90
- }),
91
- )
92
- .toBe(true);
93
-
94
- const result = await page.evaluate(() => {
95
- const ssr = (window as any).__ssrImageBlock as HTMLElement | null;
96
- return {
97
- found: !!ssr,
98
- connected: !!ssr?.isConnected,
99
- same: ssr === document.querySelector('.block-image__frame'),
100
- width: ssr?.getBoundingClientRect().width ?? 0,
101
- };
102
- });
103
- expect(result).toMatchObject({ found: true, connected: true, same: true });
104
- expect(result.width).toBeGreaterThan(0);
105
- });
106
- });
@@ -1,45 +0,0 @@
1
- import {
2
- expect,
3
- test,
4
- } from '../../../../packages/tooling/playwright/multilingual';
5
-
6
- test.describe('Multilingual root redirect', () => {
7
- test('a full load of the site root lands on the default language root', async ({
8
- page,
9
- }) => {
10
- await page.goto('/');
11
- await expect(page).toHaveURL(/\/en$/);
12
- });
13
-
14
- test('a client-side navigation to the site root lands on the default language root', async ({
15
- page,
16
- }) => {
17
- // The login action redirects to the site root once signed in. That is a
18
- // client-side navigation, which fetches /_.data, not /.
19
- await page.goto('/login', { waitUntil: 'networkidle' });
20
- await page.getByLabel('username').fill('admin');
21
- await page.getByLabel('password').fill('secret');
22
-
23
- const rootData = page.waitForRequest((request) =>
24
- /^\/_[^/]*\.data$/.test(new URL(request.url()).pathname),
25
- );
26
- await page.getByRole('button', { name: /sign in/i }).click();
27
- await rootData;
28
-
29
- await expect(page).toHaveURL(/\/en$/);
30
- });
31
-
32
- test('a language root is not redirected', async ({ page }) => {
33
- await page.goto('/de');
34
- await expect(page).toHaveURL(/\/de$/);
35
- });
36
- });
37
-
38
- test.describe('Multilingual root redirect with another default language', () => {
39
- test.use({ languages: ['de', 'en'] });
40
-
41
- test('the site root lands on the default language root', async ({ page }) => {
42
- await page.goto('/');
43
- await expect(page).toHaveURL(/\/de$/);
44
- });
45
- });
package/app/root.tsx DELETED
@@ -1,191 +0,0 @@
1
- import { useEffect, type PropsWithChildren } from 'react';
2
- import { data, isRouteErrorResponse, useRouteLoaderData } from 'react-router';
3
- import { useTranslation } from 'react-i18next';
4
- import { i18nextMiddleware, getLocale } from './i18next.server';
5
- import type { Route } from './+types/root';
6
- import config from '@plone/registry';
7
- import {
8
- ploneClearAuthCookieContext,
9
- fetchPloneContent,
10
- getAPIResourceWithAuth,
11
- contentResourceMiddleware,
12
- installServerMiddleware,
13
- PloneClientMiddleware,
14
- otherResources,
15
- ploneClientContext,
16
- ploneContentContext,
17
- ploneSiteContext,
18
- ploneUserContext,
19
- linkMiddleware,
20
- } from './middleware.server';
21
- import { getClearAuthCookieHeader } from '@plone/react-router';
22
-
23
- export const middleware = [
24
- // Install the configuration first: the i18next middleware reads the
25
- // supported languages from it.
26
- installServerMiddleware,
27
- i18nextMiddleware,
28
- PloneClientMiddleware,
29
- otherResources,
30
- getAPIResourceWithAuth,
31
- contentResourceMiddleware,
32
- fetchPloneContent,
33
- linkMiddleware,
34
- ];
35
-
36
- export async function loader({ params, request, context }: Route.LoaderArgs) {
37
- const locale = getLocale(context);
38
-
39
- const cli = context.get(ploneClientContext);
40
- const content = context.get(ploneContentContext);
41
- const site = context.get(ploneSiteContext);
42
- const user = context.get(ploneUserContext);
43
-
44
- const path = `/${params['*'] || ''}`;
45
-
46
- const rootLoaderDataUtilities = config.getUtilities({
47
- type: 'rootLoaderData',
48
- });
49
-
50
- const rootContentSubRequests = config.getUtilities({
51
- type: 'rootContentSubRequest',
52
- });
53
-
54
- try {
55
- for (const utility of rootContentSubRequests) {
56
- await utility.method({
57
- cli,
58
- content,
59
- request,
60
- path,
61
- params,
62
- locale,
63
- });
64
- }
65
-
66
- const rootLoaderDataUtilitiesData = await Promise.all([
67
- ...rootLoaderDataUtilities.map((utility) =>
68
- utility.method({
69
- cli,
70
- content,
71
- request,
72
- path,
73
- params,
74
- locale,
75
- }),
76
- ),
77
- ]);
78
-
79
- const loaderData = {
80
- content,
81
- site,
82
- locale,
83
- isAuthenticated: user !== null,
84
- // Each `rootLoaderData` utility returns a `{ status, data }` envelope
85
- // (see `config/types.ts`). Merge each utility's `data` into the root
86
- // loader data; utilities namespace their `data` to avoid clobbering.
87
- // TODO: act on `status` (e.g. propagate a non-2xx to the response).
88
- ...rootLoaderDataUtilitiesData
89
- .filter((item) => item)
90
- .reduce(
91
- (acc, item) => ({
92
- ...acc,
93
- ...(item.data as Record<string, unknown>),
94
- }),
95
- {},
96
- ),
97
- };
98
-
99
- return data(loaderData, {
100
- headers: context.get(ploneClearAuthCookieContext)
101
- ? {
102
- 'Set-Cookie': await getClearAuthCookieHeader(),
103
- }
104
- : undefined,
105
- });
106
- } catch (error: any) {
107
- throw data('Content Not Found', {
108
- status: typeof error.status === 'number' ? error.status : 500,
109
- });
110
- }
111
- }
112
-
113
- export type RootLoader = typeof loader;
114
-
115
- export const handle = {
116
- // In the handle export, we can add a i18n key with namespaces our route
117
- // will need to load. This key can be a single string or an array of strings.
118
- // TIP: In most cases, you should set this to your defaultNS from your i18n config
119
- // or if you did not set one, set it to the i18next default namespace "translation"
120
- i18n: 'common',
121
- };
122
-
123
- export function Layout({ children }: PropsWithChildren) {
124
- // React Router doesn't pass the loader data to `Layout`, and it can be
125
- // undefined in case of an error
126
- const loaderData = useRouteLoaderData<RootLoader>('root');
127
- const locale = loaderData?.locale || 'en';
128
-
129
- // Sync the i18n instance's language to the locale detected by the loader,
130
- // this way, when we do something to change the language, this locale will
131
- // change and i18next will load the correct translation files
132
- const { i18n } = useTranslation();
133
- useEffect(() => {
134
- if (i18n.language !== locale) i18n.changeLanguage(locale);
135
- }, [locale, i18n]);
136
-
137
- return children;
138
- }
139
-
140
- // ToDo: improve error page and error handling
141
- export function ErrorBoundary({ error }: Route.ErrorBoundaryProps) {
142
- let message = 'Oops!';
143
- let details = 'An unexpected error occurred.';
144
- let stack: string | undefined;
145
-
146
- if (isRouteErrorResponse(error)) {
147
- switch (error.status) {
148
- case 404:
149
- message = '404';
150
- details = 'The requested page could not be found.';
151
- break;
152
- case 401:
153
- message = '401';
154
- details = 'You are not authorized to view this page.';
155
- break;
156
- case 500:
157
- message = '500';
158
- details =
159
- 'The server encountered an internal error. Did you start the backend?';
160
- break;
161
- default:
162
- message = 'Error ' + error.status;
163
- details = error.statusText || details;
164
- break;
165
- }
166
- } else if (import.meta.env.DEV && error && error instanceof Error) {
167
- details = error.message;
168
- stack = error.stack;
169
- }
170
-
171
- return (
172
- <html lang="en">
173
- <head>
174
- <meta charSet="utf-8" />
175
- <meta name="viewport" content="width=device-width, initial-scale=1" />
176
- <meta name="mobile-web-app-capable" content="yes" />
177
- </head>
178
- <body>
179
- <main className="container mx-auto p-4 pt-16">
180
- <h1>{message}</h1>
181
- <p>{details}</p>
182
- {stack && (
183
- <pre className="w-full overflow-x-auto p-4">
184
- <code>{stack}</code>
185
- </pre>
186
- )}
187
- </main>
188
- </body>
189
- </html>
190
- );
191
- }
package/app/routes.ts DELETED
@@ -1,20 +0,0 @@
1
- import type { RouteConfig } from '@react-router/dev/routes';
2
- import type { ReactRouterRouteEntry } from '@plone/types';
3
- import { route } from '@react-router/dev/routes';
4
- import { getAddonRoutesConfig } from '@plone/react-router';
5
-
6
- // eslint-disable-next-line import/no-unresolved
7
- import addonsRoutes from '../.plone/registry.routes.json';
8
- // eslint-disable-next-line import/no-unresolved
9
- import addonsInfo from '../.plone/registry.addonsInfo.json';
10
-
11
- const routes: RouteConfig = [
12
- route('ok', 'okroute.tsx', { id: 'ok' }),
13
- route('@reset-fetcher', 'reset-fetcher.tsx', { id: 'reset-fetcher' }),
14
- ...getAddonRoutesConfig(
15
- (addonsRoutes as ReactRouterRouteEntry[]) || [],
16
- addonsInfo,
17
- ),
18
- ];
19
-
20
- export default routes;
package/news/.gitkeep DELETED
File without changes
Binary file
package/public/icon.svg DELETED
@@ -1,13 +0,0 @@
1
- <svg width="41" height="41" viewBox="0 0 41 41" fill="none" xmlns="http://www.w3.org/2000/svg">
2
- <g clip-path="url(#clip0_1_2)">
3
- <path d="M17.717 15.963C20.1482 15.963 22.119 13.9922 22.119 11.561C22.119 9.12984 20.1482 7.159 17.717 7.159C15.2858 7.159 13.315 9.12984 13.315 11.561C13.315 13.9922 15.2858 15.963 17.717 15.963Z" fill="#0083BE"/>
4
- <path d="M31.069 20.355C31.069 22.791 29.1 24.756 26.669 24.756C24.239 24.756 22.269 22.786 22.269 20.355C22.269 17.922 24.247 15.957 26.669 15.957C29.101 15.954 31.069 17.924 31.069 20.355Z" fill="#0083BE"/>
5
- <path d="M17.702 33.578C20.1331 33.578 22.104 31.6071 22.104 29.176C22.104 26.7448 20.1331 24.774 17.702 24.774C15.2708 24.774 13.3 26.7448 13.3 29.176C13.3 31.6071 15.2708 33.578 17.702 33.578Z" fill="#0083BE"/>
6
- <path d="M20.343 0C9.108 0.001 0.001 9.107 0 20.343C0.001 31.577 9.105 40.684 20.343 40.686C31.578 40.684 40.684 31.582 40.686 20.343C40.684 9.107 31.578 0.001 20.343 0ZM31.792 31.792C28.854 34.726 24.816 36.534 20.341 36.535C15.862 36.534 11.828 34.723 8.891 31.792C5.958 28.854 4.15 24.816 4.149 20.343C4.15 15.865 5.96 11.83 8.892 8.893C11.83 5.959 15.864 4.151 20.342 4.15C24.82 4.151 28.855 5.962 31.792 8.893C34.727 11.831 36.534 15.869 36.536 20.343C36.535 24.819 34.726 28.854 31.792 31.792Z" fill="#0083BE"/>
7
- </g>
8
- <defs>
9
- <clipPath id="clip0_1_2">
10
- <rect width="40.686" height="40.686" fill="white"/>
11
- </clipPath>
12
- </defs>
13
- </svg>
@@ -1,11 +0,0 @@
1
- import type { Config } from '@react-router/dev/config';
2
-
3
- export default {
4
- ssr: true,
5
- // The build directory may be named by the environment, so a deployment can build
6
- // ASIDE into a versioned directory (for example build.live-<stamp>) and then swap a
7
- // symlink, instead of writing into the directory a running server is serving from —
8
- // `react-router build` removes its build directory before it writes. Unset, the
9
- // default `build` is unchanged.
10
- buildDirectory: process.env.REACT_ROUTER_BUILD_DIR || 'build',
11
- } satisfies Config;
@@ -1,11 +0,0 @@
1
- const addons = [
2
- '@plone/theming',
3
- '@plone/plate',
4
- '@plone/blocks',
5
- '@plone/layout',
6
- '@plone/publicui',
7
- '@plone/agave',
8
- ];
9
- const theme = '';
10
-
11
- export { addons, theme };
@@ -1,16 +0,0 @@
1
- const addons = [
2
- '@plone/theming',
3
- '@plone/plate',
4
- '@plone/blocks',
5
- '@plone/layout',
6
- '@plone/cmsui',
7
- '@plone/publicui',
8
- '@plone/contents',
9
- '@plone/controlpanels',
10
- '@plone/agave',
11
- // Blocks and fields for the acceptance and visual regression tests only.
12
- ...(process.env.PLONE_TEST_ADDON ? ['@plone/test-addon'] : []),
13
- ];
14
- const theme = '';
15
-
16
- export { addons, theme };
package/tests/setup.ts DELETED
@@ -1,6 +0,0 @@
1
- import '@testing-library/jest-dom';
2
-
3
- import { vi } from 'vitest';
4
-
5
- // @ts-expect-error "required by jest"
6
- globalThis.jest = vi;
@@ -1,29 +0,0 @@
1
- import { render } from '@testing-library/react';
2
- import i18next from 'i18next';
3
- import LanguageDetector from 'i18next-browser-languagedetector';
4
- import React from 'react';
5
- import { I18nextProvider, initReactI18next } from 'react-i18next';
6
-
7
- import { getI18nOptions } from '../app/i18n';
8
-
9
- /**
10
- * Use this function to render a component with the i18next provider
11
- * @param children The route Stub to render
12
- */
13
- export async function renderWithI18n(children: React.ReactNode) {
14
- await i18next
15
- .use(initReactI18next)
16
- .use(LanguageDetector)
17
- .init({
18
- ...getI18nOptions(),
19
- ns: ['common'],
20
- detection: {
21
- order: ['htmlTag'],
22
- caches: [],
23
- },
24
- });
25
- const result = render(
26
- <I18nextProvider i18n={i18next}>{children}</I18nextProvider>,
27
- );
28
- return result;
29
- }
package/towncrier.toml DELETED
@@ -1,33 +0,0 @@
1
- [tool.towncrier]
2
- filename = "CHANGELOG.md"
3
- directory = "news/"
4
- title_format = "## {version} ({project_date})"
5
- underlines = ["", "", ""]
6
- template = "../../packages/scripts/templates/towncrier_template.jinja"
7
- start_string = "<!-- towncrier release notes start -->\n"
8
- issue_format = "[#{issue}](https://github.com/plone/aurora/issues/{issue})"
9
-
10
- [[tool.towncrier.type]]
11
- directory = "breaking"
12
- name = "Breaking"
13
- showcontent = true
14
-
15
- [[tool.towncrier.type]]
16
- directory = "feature"
17
- name = "Feature"
18
- showcontent = true
19
-
20
- [[tool.towncrier.type]]
21
- directory = "bugfix"
22
- name = "Bugfix"
23
- showcontent = true
24
-
25
- [[tool.towncrier.type]]
26
- directory = "internal"
27
- name = "Internal"
28
- showcontent = true
29
-
30
- [[tool.towncrier.type]]
31
- directory = "documentation"
32
- name = "Documentation"
33
- showcontent = true
package/tsconfig.json DELETED
@@ -1,35 +0,0 @@
1
- {
2
- "include": [
3
- "**/*.ts",
4
- "**/*.tsx",
5
- "**/.server/**/*.ts",
6
- "**/.server/**/*.tsx",
7
- "**/.client/**/*.ts",
8
- "**/.client/**/*.tsx",
9
- ".react-router/types/**/*"
10
- ],
11
- "exclude": ["packages/*"],
12
- "compilerOptions": {
13
- "lib": ["DOM", "DOM.Iterable", "ES2022"],
14
- "types": ["@react-router/node", "vite/client", "@plone/icons/svg"],
15
- "isolatedModules": true,
16
- "esModuleInterop": true,
17
- "jsx": "react-jsx",
18
- "module": "ESNext",
19
- "moduleResolution": "Bundler",
20
- "resolveJsonModule": true,
21
- "target": "ES2022",
22
- "strict": true,
23
- "allowJs": true,
24
- "skipLibCheck": true,
25
- "forceConsistentCasingInFileNames": true,
26
- "paths": {
27
- "~/*": ["./app/*"],
28
- "@plone/aurora/*": ["./*"],
29
- "@plone/plate/*": ["../../packages/plate/src/*"]
30
- },
31
- "noEmit": true,
32
- "rootDirs": [".", "./.react-router/types"],
33
- "plugins": [{ "name": "@react-router/dev" }]
34
- }
35
- }
package/vite.config.ts DELETED
@@ -1,120 +0,0 @@
1
- import { reactRouter } from '@react-router/dev/vite';
2
- import path from 'node:path';
3
- import { defineConfig, PluginOption } from 'vite';
4
- import { PloneRegistryVitePlugin } from '@plone/registry/vite-plugin';
5
- import { PloneDevtoolsVitePlugin } from '@plone/devtools/vite';
6
- import { PloneSVGRVitePlugin } from '@plone/icons/vite-plugin-svgr';
7
- import applyAddonViteConfiguration from './.plone/vite.loader.js';
8
- import babel from 'vite-plugin-babel';
9
- import tailwindcss from '@tailwindcss/vite';
10
- import { visualizer } from 'rollup-plugin-visualizer';
11
- import devtoolsJson from 'vite-plugin-devtools-json';
12
-
13
- export default defineConfig(({ command, mode, isSsrBuild }) => {
14
- const analyze = process.env.ANALYZE === 'true';
15
- const target = isSsrBuild ? 'server' : 'client';
16
- const statsDir = path.resolve(import.meta.dirname, 'build', 'stats');
17
-
18
- const baseConfig = {
19
- plugins: [
20
- // Development only. Set PLONE_DEVTOOLS=false to turn it off.
21
- ...PloneDevtoolsVitePlugin(),
22
- PloneSVGRVitePlugin(),
23
- PloneRegistryVitePlugin(),
24
- tailwindcss(),
25
- reactRouter(),
26
- babel({
27
- include: /\.tsx?$/,
28
- exclude: /node_modules/,
29
- babelConfig: {
30
- presets: ['@babel/preset-typescript'],
31
- plugins: ['babel-plugin-react-compiler'],
32
- },
33
- }),
34
- devtoolsJson(),
35
- ...(analyze
36
- ? [
37
- visualizer({
38
- filename: path.join(statsDir, `stats-${target}.html`),
39
- template: 'treemap',
40
- gzipSize: true,
41
- brotliSize: true,
42
- }),
43
- visualizer({
44
- filename: path.join(statsDir, `stats-${target}.json`),
45
- template: 'raw-data',
46
- gzipSize: true,
47
- brotliSize: true,
48
- }),
49
- ]
50
- : []),
51
- ] as PluginOption[],
52
- optimizeDeps: {
53
- // Server-only deps that Vite would otherwise still pick up for the
54
- // client bundle — keep in sync with ssr.optimizeDeps.include below
55
- exclude: [
56
- 'i18next-fs-backend',
57
- 'i18next-fs-backend/cjs',
58
- 'remix-i18next',
59
- ],
60
- include: [
61
- // App-level deps (in apps/aurora/package.json)
62
- 'i18next',
63
- 'i18next-browser-languagedetector',
64
- 'i18next-http-backend',
65
- 'react-i18next',
66
- // Injected by babel-plugin-react-compiler, not in any package.json
67
- 'react/compiler-runtime',
68
- // @plone/components, @plone/icons, @plone/quanta and @plone/helpers are
69
- // not registered add-ons, so their deps can't be declared in
70
- // vite.extend.js — list them here
71
- '@plone/components > clsx',
72
- '@plone/components > react-aria',
73
- '@plone/components > react-aria-components',
74
- '@plone/icons > @react-aria/utils',
75
- '@plone/icons > @react-spectrum/utils',
76
- '@plone/icons > clsx',
77
- '@plone/icons > tailwind-variants',
78
- '@plone/quanta > @internationalized/date',
79
- '@plone/quanta > clsx',
80
- '@plone/quanta > react-aria-components',
81
- '@plone/quanta > react-aria-components/DropZone',
82
- '@plone/quanta > react-aria-components/Form',
83
- '@plone/quanta > react-aria-components/Group',
84
- '@plone/quanta > react-aria-components/Modal',
85
- '@plone/quanta > react-aria-components/Table',
86
- '@plone/quanta > react-aria-components/Tooltip',
87
- '@plone/quanta > react-aria-components/composeRenderProps',
88
- '@plone/quanta > tailwind-merge',
89
- '@plone/quanta > tailwind-variants',
90
- '@plone/quanta > usehooks-ts',
91
- '@plone/helpers > jotai',
92
- '@plone/helpers > jotai/utils',
93
- '@plone/helpers > jotai/vanilla',
94
- '@plone/helpers > jotai-optics',
95
- ],
96
- },
97
- ssr: {
98
- optimizeDeps: {
99
- include: ['i18next-fs-backend/cjs', 'isbot', 'remix-i18next'],
100
- },
101
- },
102
- resolve: {
103
- tsconfigPaths: true,
104
- },
105
- server: {
106
- port: 3000,
107
- fs: {
108
- // Allow serving files from one level up to the project root
109
- // (required by the Cookieplone setup)
110
- allow: ['../../../.'],
111
- },
112
- },
113
- };
114
-
115
- return applyAddonViteConfiguration(baseConfig, {
116
- command,
117
- mode,
118
- isSsrBuild,
119
- });
120
- });