Closed MarkL4YG closed 2 years ago
The public directory should not be an absolute path, but instead a relative path for Laravel.
Also, this should only be set if you are changing the public directory in your Laravel project.
If your public directory was `"public_html", you would set this to:
publicDirectory: 'public_html',
Try setting it relative and let us know if you have any issues.
@timacdonald Correct me if I'm wrong, but Laravel itself seems free of this limitation. I could set my Laravel's public path to anywhere (of course I would also need to change the hard-coded paths in index.php
) and it would work without problem. So it's a bit strange I can't do this in the vite plugin. Could you give us the rationale behind this restriction?
@monyxie this issue seems related to relative vs absolute paths rather than any kind of restriction? What restriction are you referring to?
@timacdonald I was referring to the restriction that it's not possible to use a directory outside of project root as the public directory, for the fact that the output files still ends up in a subdirectory in the project root when publicDirectory
is set to an absolute path. However, I've now come to realize that it is not the case and I can do it with ..
.
I'm terribly sorry for not thinking this through before commenting.
Hi there 👋🏼
I'm quite new to using Vite and Laravel together but I'm already excited on the benefits of using Vite. It appears, I've stumbled on a bug that appears when this plugin generates the Vite
outDir
on Unix-like systems.Since this bug seems fairly straight forward, I've not taken the time to confirm it on a fresh Laravel project. Let me know if you want me to confirm it from there in case it turns out to not be that clear.
Versions (from lockfiles)
0.5.3
v9.22.1
v16.16.0
8.11.0
103.0.2 (64-bit)
(but should be not applicable)Description:
When setting
publicDirectory
to an absolute path, the build output appears empty on Unix systems.The reason is that the leading slash goes missing in the generated Vite option
build.outDir
which causes the output to be written to a relative path and not the expected one.Example
vite.config.js
Using
npx vite build --debug --mode development
, the resulting Vite configuration can be examined:Steps To Reproduce:
path.resolve(...)
vite build
inside any Unix environment.Workaround:
Manually setting
build.ourDir
invite.config.js
resolves the issue as the path is no longer generated by this plugin.