You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Create a Vue CLI 4 project in the Laravel '/resources/frontend/'
cd resources/frontendvue create app#and (if you need admin build)vue create admin
Configure Vue CLI 4 project
Create/resources/frontend/app/vue.config.js:
module.exports={devServer:{proxy:'http://laravel.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/assets/app',publicPath:process.env.NODE_ENV==='production' ?'/assets/app/' :'/',// modify the location of the generated HTML file.indexPath:process.env.NODE_ENV==='production' ?'../../../resources/views/app.blade.php' :'index.html'}
module.exports={// proxy API requests to Valet during developmentdevServer:{proxy:'http://laravel.test/admin'},// output built static files to Laravel's public dir.// note the "build" script in package.json needs to be modified as well.outputDir:'../../../public/assets/admin',publicPath:process.env.NODE_ENV==='production' ?'/assets/admin/' :'/admin',// modify the location of the generated HTML file.// make sure to do this only in production.indexPath:process.env.NODE_ENV==='production' ?'../../../resources/views/admin.blade.php' :'index.html'}
<?php// For admin applicationRoute::get('/admin{any}','FrontendController@admin')->where('any','.*');// For public applicationRoute::any('/{any}','FrontendController@app')->where('any','^(?!api).*$');
app/Http/Controllers/FrontendController.php
<?phpnamespaceApp\Http\Controllers;useIlluminate\Http\Request;class FrontendControllerextends Controller{// For admin applicationpublicfunctionadmin() {returnview('admin'); }// For public applicationpublicfunctionapp() {returnview('app'); }}
Changebase: process.env.BASE_URL inrouter.js for correct Vue Router
// For Appbase:'/',// For Adminbase:'/admin/',
Addpackage.json in root (if you want useyarn run in root)
{"name":"laravel","version":"0.2.0","private":true,"scripts":{// For public application"prepare:app":"cd resources/frontend/app && yarn install","serve:app":"cd resources/frontend/app && yarn run serve","build:app":"cd resources/frontend/app && yarn run build","lint:app":"cd resources/frontend/app && yarn run lint","test:app":"cd resources/frontend/app && yarn run test:unit",// For admin application"prepare:admin":"cd resources/frontend/admin && yarn install","serve:admin":"cd resources/frontend/admin && yarn run serve","build:admin":"cd resources/frontend/admin && yarn run build","lint:admin":"cd resources/frontend/admin && yarn run lint","test:admin":"cd resources/frontend/admin && yarn run test:unit"}}