

GitHub - yyx990803/laravel-vue-cli-3: Example project using Vue CLI 3 with Larav...
source link: https://github.com/yyx990803/laravel-vue-cli-3
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

README.md
Laravel + Vue CLI 3
This demo assumes you are serving this Laravel app via Valet at laracon.test
. If you are serving the laravel app at a different local URL, modify it accordingly in frontend/vue.config.js
.
To Run the Frontend
cd frontend yarn # OR npm install yarn serve # OR npm run serve # build for production: yarn build # OR npm run build
Steps for Scaffolding From Scratch
-
Create Laravel Project
laravel new my-project cd my-project # remove existing frontend scaffold rm -rf package.json webpack.mix.js yarn.lock resources/assets
-
Create a Vue CLI 3 project in the Laravel app
vue create frontend # pick router
-
Configure Vue project
Create
frontend/vue.config.js
:module.exports = { // proxy API requests to Valet during development // adjust according to your dev setup devServer: { proxy: 'http://laracon.test' }, // output built static files to Laravel's public dir. // note the "build" script in package.json needs to be modified as well. outputDir: '../public', // modify the location of the generated HTML file. // make sure to do this only in production. chainWebpack: config => { if (process.env.NODE_ENV === 'production') { config.plugin('html').tap(opts => { opts[0].filename = '../resources/views/index.blade.php' return opts }) } } }
Edit
frontend/package.json
:"scripts": { "serve": "vue-cli-service serve", - "build": "vue-cli-service build", + "build": "rm -rf ../public/{js,css,img} && vue-cli-service build --no-clean", "lint": "vue-cli-service lint" },
-
Configure Laravel for single-page app.
routes/web.php
<?php Route::get('/{any}', 'SpaController@index')->where('any', '.*');
app/Http/Controllers/SpaController.php
<?php namespace App\Http\Controllers; use Illuminate\Http\Request; class SpaController extends Controller { public function index() { return view('index'); } }
Recommend
-
210
Files Permalink Latest commit message Commit ti...
-
231
Laravel 8.0 blog The purpose of this repository is to show good development practices on Laravel as well as to present cases of use of the framework's features like: Beside Laravel...
-
56
README.md vue-hooks POC for using React Hooks in Vue. Totally experimental, don't use this in p...
-
45
README.md Build Your Own Mint Important Disclaimer Credentials are stored in lib/credentials.json. (Note this file is in...
-
48
A proposal that consolidates upon #22 (Advanced Reactivity API), #23 (Dynamic Lifecycle Injection) and the discontinuation of #17 (Class API).Full Rendered ProposalHigh-level Q&AIs this like Python 3 / Angular 2 / Do I have to rewrite all my...
-
16
November 21, 2020 Upload Image To Database Using Laravel Tutorial With ExampleWith Laravel, you can forget...
-
7
Comparing generated code size of Vue and Svelte components TL;DR Compiled Svelte component code is 70% heavier than Vue 3 equivalent, and 110% heavier in SSR mode. It takes ~
-
5
Laravel 7 Send Mail Using Markdown Example 8646 views 1 year ago Laravel Today, markdown laravel 7 mail i...
-
12
Laravel 8 Authentication using Jetstream Example In this example, we will discuss laravel 8 authentication using jetstream example. In this post, I will give you a simple and easy example of laravel...
-
3
wsk.example A sample starter project using wsk. View at: https://bloomberg.github.io/wsk.example ...
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK