A simple ecommerce project using laravel and vue
-
laravel new ecommerce
-
npm install vue@next vue-loader@next
-
npm install
-
Create app.vue and create a vue app in app.js
-
- app.js file will look like this
import "./bootstrap"; import { createApp } from "vue"; import app from "./layouts/app.vue"; createApp(app).mount("#app");
-
- app.vue file will look like this
<template> <div id="app"> <h1>hello world</h1> </div> </template>
-
- the body section on welcome.blade.php file will look like this
<body> <div id="app"></div> @vite('resources/js/app.js') </body>
-
-
install vitejs vue plugin and add it to the vite.config.js
npm install @vitejs/plugin-vue
import { defineConfig } from "vite"; import laravel from "laravel-vite-plugin"; import vue from "@vitejs/plugin-vue"; export default defineConfig({ plugins: [ vue(), laravel({ input: ["resources/css/app.css", "resources/js/app.js"], refresh: true, }), ], });
-
run
npm run dev
andphp artisan serve
to see the result