From 0f68884531cdaa4a0db96af0c98c0644259c29e9 Mon Sep 17 00:00:00 2001 From: Olivier Tassinari Date: Thu, 1 Feb 2024 12:50:27 +0100 Subject: [PATCH] [docs-infra] Allow developers to build their CodeSandbox export (#40878) --- docs/src/modules/sandbox/CodeSandbox.test.js | 9 +++++++++ docs/src/modules/sandbox/CodeSandbox.ts | 18 ++++++++++++------ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/docs/src/modules/sandbox/CodeSandbox.test.js b/docs/src/modules/sandbox/CodeSandbox.test.js index 7b04b67adb0233..887ad748a63304 100644 --- a/docs/src/modules/sandbox/CodeSandbox.test.js +++ b/docs/src/modules/sandbox/CodeSandbox.test.js @@ -41,6 +41,12 @@ describe('CodeSandbox', () => { devDependencies: { 'react-scripts': 'latest', }, + scripts: { + start: 'react-scripts start', + build: 'react-scripts build', + test: 'react-scripts test', + eject: 'react-scripts eject', + }, }, }, 'public/index.html': { @@ -130,7 +136,10 @@ ReactDOM.createRoot(document.querySelector("#root")).render( }, main: 'index.tsx', scripts: { + build: 'react-scripts build', + eject: 'react-scripts eject', start: 'react-scripts start', + test: 'react-scripts test', }, }, }, diff --git a/docs/src/modules/sandbox/CodeSandbox.ts b/docs/src/modules/sandbox/CodeSandbox.ts index 44b007be440ac2..0df110fbc68cac 100644 --- a/docs/src/modules/sandbox/CodeSandbox.ts +++ b/docs/src/modules/sandbox/CodeSandbox.ts @@ -63,11 +63,14 @@ function createReactApp(demoData: DemoData) { description, dependencies, devDependencies, + scripts: { + start: 'react-scripts start', + build: 'react-scripts build', + test: 'react-scripts test', + eject: 'react-scripts eject', + }, ...(demoData.codeVariant === 'TS' && { main: 'index.tsx', - scripts: { - start: 'react-scripts start', - }, }), }, }; @@ -155,11 +158,14 @@ ReactDOM.createRoot(document.querySelector("#root")${type}).render( description, dependencies, devDependencies, + scripts: { + start: 'react-scripts start', + build: 'react-scripts build', + test: 'react-scripts test', + eject: 'react-scripts eject', + }, ...(templateData.codeVariant === 'TS' && { main: 'index.tsx', - scripts: { - start: 'react-scripts start', - }, }), }, };