Skip to content

Commit

Permalink
fix(admin): load app custom with jsx and allow more extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandrebodin committed Nov 13, 2023
1 parent ecfbf5e commit 8ac0ef5
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions examples/getstarted/jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"compilerOptions": {
"jsx": "react",
"moduleResolution": "nodenext",
"target": "ES2021",
"checkJs": true,
Expand Down
12 changes: 11 additions & 1 deletion examples/getstarted/src/admin/app.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,18 @@
import React from 'react';
import { Button } from '@strapi/design-system';

const config = {
locales: ['it', 'es', 'en'],
};
const bootstrap = () => {
const bootstrap = (app) => {
console.log('I AM BOOTSTRAPPED');

app.injectContentManagerComponent('editView', 'right-links', {
name: 'PreviewButton',
Component: () => (
<Button onClick={() => window.alert('Not here, The preview is.')}>Preview</Button>
),
});
};

export default {
Expand Down
6 changes: 5 additions & 1 deletion packages/core/admin/_internal/node/core/files.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,11 @@ const pathExists = async (path: string) => {
*/
const loadFile = async (path: string): Promise<undefined | any> => {
if (await pathExists(path)) {
const esbuildOptions = { extensions: ['.js', '.mjs', '.ts'] };
const esbuildOptions: Parameters<typeof register>[0] = {
extensions: ['.js', '.mjs', '.ts', '.jsx', '.tsx'],
jsx: 'automatic',
loader: 'jsx',
};

const { unregister } = register(esbuildOptions);

Expand Down
4 changes: 2 additions & 2 deletions packages/core/admin/_internal/node/staticFiles.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ const getEntryModule = (ctx: BuildContext): string => {
*/
${pluginsImport}
import { renderAdmin } from "@strapi/strapi/admin"
${
ctx.customisations?.path
? `import customisations from '${path.relative(
Expand All @@ -33,7 +33,7 @@ const getEntryModule = (ctx: BuildContext): string => {
)}'`
: ''
}
renderAdmin(
document.getElementById("strapi"),
{
Expand Down

0 comments on commit 8ac0ef5

Please sign in to comment.