React: Difference between revisions

From DiviFree
(Created page with "==Déployer un app react== * https://create-react-app.dev/docs/deployment/ * https://stackoverflow.com/questions/57090744/how-do-i-configure-my-htaccess-file-for-react-app-in-subdirectory Build the project ( <pre> npm run build </pre> .htaccess <pre> <IfModule mod_rewrite.c> RewriteEngine On RewriteBase /subdirectory RewriteRule ^index\.html$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteCond %{REQUEST_FILENAME} !-l RewriteRule ....")
 
No edit summary
 
(One intermediate revision by the same user not shown)
Line 3: Line 3:
* https://stackoverflow.com/questions/57090744/how-do-i-configure-my-htaccess-file-for-react-app-in-subdirectory
* https://stackoverflow.com/questions/57090744/how-do-i-configure-my-htaccess-file-for-react-app-in-subdirectory


Build the project (
Start the projet
<pre>
npm start
</pre>
 
Build the project (to deploy)
<pre>
<pre>
npm run build
npm run build
Line 19: Line 24:
RewriteRule . /index.html [L]
RewriteRule . /index.html [L]
</IfModule>
</IfModule>
</pre>
==Erreur==
'react-scripts' n’est pas reconnu en tant que commande interne
<pre>
npm install react-scripts --save
</pre>
</pre>

Latest revision as of 18:46, 28 March 2023

Déployer un app react

Start the projet

npm start

Build the project (to deploy)

npm run build

.htaccess

<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /subdirectory
RewriteRule ^index\.html$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteCond %{REQUEST_FILENAME} !-l
RewriteRule . /index.html [L]
</IfModule>

Erreur

'react-scripts' n’est pas reconnu en tant que commande interne

npm install react-scripts --save