Coder Social home page Coder Social logo

cba85 / laravel8-jetstream-inertia-vue3 Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 861 KB

Simple example of a Laravel 8 app using Jetstream and Inertia with Vue 3

Shell 0.37% PHP 46.27% Vue 38.89% Blade 14.47%
inertiajs laravel-jetstream laravel8 vue3

laravel8-jetstream-inertia-vue3's Introduction

Laravel Jetstream Inertia Vue 3

Simple example of a Laravel 8 app using Jetstream and Inertia with Vue 3.

Steps

  1. Create a new Laravel Jetstream application

    $ laravel new laravel-jetstream-inertia-vue3
  2. Install Laravel Mix 6 (beta)

    $ npm install laravel-mix@next

    See https://github.com/JeffreyWay/laravel-mix/blob/master/UPGRADE.md

  3. Update scripts and devDependencies objects in package.json file:

    {
        "private": true,
        "scripts": {
            "dev": "npx mix",
            "development": "npx mix",
            "watch": "npx mix watch",
            "hot": "npx mix hot",
            "prod": "npx mix --production",
            "production": "npx mix --production"
        },
        "devDependencies": {
            "@inertiajs/inertia": "^0.4.0",
            "@inertiajs/inertia-vue3": "^0.1.0",
            "@vue/compiler-sfc": "^3.0.0",
            "axios": "^0.20.0",
            "laravel-mix": "^6.0.0-beta.5",
            "vue": "^3.0.0",
            "vue-loader": "^16.0.0-beta.8",
            "@tailwindcss/ui": "^0.6.0",
            "cross-env": "^7.0",
            "laravel-jetstream": "^0.0.3",
            "lodash": "^4.17.19",
            "portal-vue": "^2.1.7",
            "postcss-import": "^12.0.1",
            "resolve-url-loader": "^3.1.0",
            "tailwindcss": "^1.8.0"
        }
    }
  4. Install the new dependencies:

    $ npm i
  5. Update webpack.mix.json file:

    const mix = require("laravel-mix");
    const path = require("path");
    
    mix.postCss("resources/css/app.css", "public/css", [
        require("postcss-import"),
        require("tailwindcss")
    ])
        .js("resources/js/app.js", "public/js")
        .vue({ version: 3 });
    
    mix.alias({
        "@": path.resolve("resources/js")
    });
  6. Update /resources/js/app.js file to use inertia and vue 3:

    import { createApp, h } from "vue";
    
    import { app, plugin } from "@inertiajs/inertia-vue3";
    
    const el = document.getElementById("app");
    
    createApp({
        render: () =>
            h(app, {
                initialPage: JSON.parse(el.dataset.page),
                resolveComponent: name =>
                    import(`@/Pages/${name}`).then(module => module.default)
            })
    })
        .use(plugin)
        .mount(el);

    See https://github.com/inertiajs/inertia/releases/tag/inertia-vue3%40v0.1.0

  7. Launch npm mix to let it installs additional dependencies:

    $ npm run dev
  8. Re-launch npm mix:

    $ npm run dev

    You should obtain an error:

    VueCompilerError: <template v-for> key should be placed on the <template> tag.
  9. Update /resources/js/Layouts/AppLayout.vue file on line 179 to move :key="team.id" from <form> element to its parent <template> element:

    <template v-for="team in $page.user.all_teams" :key="team.id">
    <form @submit.prevent="switchToTeam(team)">
  10. Done πŸ₯³

    DONE  Compiled successfully in 8719ms                                                      4:48:19 PM
    
    99% done plugins BuildOutputPlugin
    
    Laravel Mix v6.0.0-beta.10
    
    βœ” Compiled Successfully in 8719ms
    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
    β”‚ File                              β”‚ Size     β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
    β”‚ css/app.css                       β”‚ 4.38 MiB β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
    β”‚ /js/app.js                        β”‚ 1.14 MiB β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
    β”‚ js/resources_js_Pages_Profile_Sh… β”‚ 367 KiB  β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
    β”‚ js/resources_js_Pages_API_Index_… β”‚ 289 KiB  β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
    β”‚ js/resources_js_Pages_API_ApiTok… β”‚ 178 KiB  β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
    β”‚ js/resources_js_Pages_Profile_Tw… β”‚ 135 KiB  β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
    β”‚ js/resources_js_Pages_Dashboard_… β”‚ 128 KiB  β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
    β”‚ js/resources_js_Pages_Profile_Lo… β”‚ 115 KiB  β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
    β”‚ js/resources_js_Pages_Profile_De… β”‚ 109 KiB  β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
    β”‚ js/resources_js_Pages_Profile_Up… β”‚ 99 KiB   β”‚
    β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
    β”‚ js/resources_js_Pages_Profile_Up… β”‚ 82.5 KiB β”‚
    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

laravel8-jetstream-inertia-vue3's People

Contributors

cba85 avatar

Watchers

 avatar

Forkers

ollivr

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.