Blade @vite directive not detecting public/build Folder
See original GitHub issue- Laravel Vite Plugin Version: ^0.4.0
- Laravel Version: ^9.19.0
- Node Version: 18.6.0
- NPM Version: 8.13.2
- Host operating system: macOS 10.15.7
- Web Browser & Version: Chrome 104.0.5112.48
- Running in Sail / Docker: No
Description: Running npm run dev works well but when I run npm run build, the build folder is created as expected in public/build but the @vite direction in blade isn’t picking up the build folder at all. It keeps looking for @vite/client even though it is no longer in dev mode.
Steps To Reproduce:
- Run
npm run build
after installing all the packages. - In the main blade entry file, add
@vite(['resources/js/app.js'])
(I tried adding the build directory too@vite(['resources/js/app.js'], 'build')
and that didn’t work) - Visit the site in the browser and it should fail showing an net::ERR_CONNECTION_REFUSED in console.
This is my vite.config.js file:
import { defineConfig } from "vite";
import fs from "fs";
import { homedir } from "os";
import laravel from "laravel-vite-plugin";
import { resolve } from "path";
import vue from "@vitejs/plugin-vue";
let host = "stats.test";
export default defineConfig({
plugins: [
laravel("resources/js/app.js"),
vue({
template: {
transformAssetUrls: {
base: null,
includeAbsolute: false,
},
},
}),
],
resolve: {
alias: {
src: resolve(__dirname, "resources/js"),
modules: resolve(__dirname, "resources/js/components/modules"),
frontend: resolve(__dirname, "resources/js/components/frontend"),
vendor: resolve(__dirname, "resources/js/vendor"),
lang: resolve(__dirname, "resources/languages"),
},
},
server: detectServerConfig(host),
});
function detectServerConfig(host) {
let keyPath = resolve(homedir(), `.config/valet/Certificates/${host}.key`);
let certPath = resolve(homedir(), `.config/valet/Certificates/${host}.crt`);
if (!fs.existsSync(keyPath)) {
return {};
}
if (!fs.existsSync(certPath)) {
return {};
}
return {
hmr: { host },
host,
https: {
key: fs.readFileSync(keyPath),
cert: fs.readFileSync(certPath),
},
};
}
Issue Analytics
- State:
- Created a year ago
- Reactions:1
- Comments:7 (4 by maintainers)
Top Results From Across the Web
Laravel Vite Deploying to Host - Laracasts
It exported css and javascript to public/build folder. ... Now in my blade view, I call the @vite directive with the input file...
Read more >Why Laravel Vite Directive Not Working in My Project?
Then this new blade directive must work properly. ... These can be found in the resources/views/components folder of your app.
Read more >vite-plugin/UPGRADE.md at main · laravel/vite-plugin - GitHub
When using Vite, you will need to use the @vite Blade directive instead of the mix() helper. This will automatically detect whether you...
Read more >Asset Bundling (Vite) - The PHP Framework For Web Artisans
Laravel integrates seamlessly with Vite by providing an official plugin and Blade directive to load your assets for development and production. Are you...
Read more >laravel vite manifest not found at - You.com | The AI Search ...
It turns out the files in /public/build folder are not committed in the git repository, thus missing on production server. Should I? Install...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This will happen if the
public/hot
file still exists.check that you haven’t accidentally committed this file to the project repository. If it exists, delete it.
The plug-in should automatically delete it when it shuts down the HMR server, but potentially you committed the file while it was running.
If that isn’t the case, let us know.
@timacdonald It’s in my
.gitignore
file for sure (from my laravel mix days) but I usually run build locally and push build files to my prod server.