1

I am a newbie learning Vue.js and I am using it with Laravel. I have decent experience with Laravel. Previously, without any frontend setup, I simply used to go to http://localhost/my-project/public and my Laravel homepage would display as everything used to be in the public directory.

Now I am using Vue with Vite as my build tool. After running npm run build, the build assets by Vite are placed inside public/build directory. I run the dev environment using npm run dev and php artisan server and I can access the app on http://localhost:8000 but how do I access my app without using Artisa or without any dev servers running?

This is my /public directory structure:

│   .htaccess
│   favicon.ico
│   index.php
│   robots.txt
│
├───build
│   │   manifest.json
│   │
│   └───assets
│           app.5bcb0e65.js
│           app.dd96aa6d.css
            ..other images, fonts

Currently, When I go to the URL http://localhost/my-project/public/dashboard, I see nothing but a blank white screen and an error in the console saying [Vue Router warn]: No match found for location with path "/my-project/public/dashboard" but with php artisan server, I can access http://localhost:8000/dashboard without any issues.

This is my routes\web.php file contents:

...

Route::any('/', function () {
    return view('welcome');
});

Route::any('/{slug}', function () {
    return view('welcome');
})->where('slug', '([A-z\d\-\/_.]+)?');

iamsubingyawali
  • 193
  • 1
  • 2
  • 15
  • once you're ready to ship, run the following command ``npm install && npm run build`` in the root folder of the project. – OMi Shah Aug 22 '22 at 18:08
  • Did it. Actually, I am not having difficulties creating a production build, instead, I want a way to access that production build. The production build is placed inside `public\build` folder by vite but how do I access the resources without artisan? When I go to the URL `http://localhost/my-project/public/dashboard` I see nothing but a blank white screen and an error in the console saying `[Vue Router warn]: No match found for location with path "/my-project/public/dashboard"` but with php artisan server, I can access `http://localhost:8000/dashboard` without any issues. – iamsubingyawali Aug 22 '22 at 18:24

0 Answers0