Coder Social home page Coder Social logo

react-laravel2022's Introduction

  1. Crear proyecto jetstream - livewire
    • $ laravel new prueba --jet
  2. Crear base de datos del proyecto
  3. $ php artisan migrate
  4. En package.json eleminar dependencias:
    • "laravel-vite-plugin": "^0.6.0",
    • "vite": "^3.0.0",
  5. $ npm install vite laravel-vite-plugin --save-dev
  6. $ npm install @vitejs/plugin-react --force
  7. $ npm install react@latest react-dom@latest
    • Nota: en caso de problemas:
      • $ npm install react@latest react-dom@latest --force
  8. Modificar vite.config.js:
    import { defineConfig } from 'vite';
    import laravel, { refreshPaths } from 'laravel-vite-plugin';
    import react from '@vitejs/plugin-react';
    
    export default defineConfig({
        plugins: [
            react(),
            laravel({
                input: [
                    'resources/css/app.css',
                    'resources/js/app.js',
                ],
                refresh: [
                    ...refreshPaths,
                    'app/Http/Livewire/**',
                ],
            }),
        ],
    });
  9. Crear resources\js\components\App.jsx:
    import React from 'react';
    
    const App = () => {
        return (
            <div>
                <h1>Laravel 9, vite y react</h1>
            </div>
        )
    }
    
    export default App;
  10. Cambiar nombre de resources\js\app.js a resources\js\app.jsx.
  11. Modificar resources\js\app.jsx:
    import './bootstrap';
    
    import React from 'react';
    import ReactDOM from 'react-dom';
    import App from './components/App';
    
    import Alpine from 'alpinejs';
    
    window.Alpine = Alpine;
    
    Alpine.start();
    
    if (document.getElementById('app')) {
        ReactDOM.render(<App />, document.getElementById('app'));
    }
  12. Modificar resources\views\welcome.blade.php:
    <!DOCTYPE html>
    <html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
        <head>
            <meta charset="utf-8">
            <meta name="viewport" content="width=device-width, initial-scale=1">
    
            <title>Laravel</title>
    
            <!-- Fonts -->
            <link href="https://fonts.bunny.net/css2?family=Nunito:wght@400;600;700&display=swap" rel="stylesheet">
            @viteReactRefresh
            @vite(['resources/css/app.css', 'resources/js/app.jsx'])
        </head>
        <body>
            <div id='app'></div>
        </body>
    </html>

Subir a GitHub:

  1. Crear proyecto en la página de GitHub con el nombre: react-laravel2022.
    • Description: Ejemplo de una aplicación Laravel con React.js.
    • Public.
  2. En la ubicación raíz del proyecto en la terminal de la máquina local:

react-laravel2022's People

Contributors

petrix12 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.