In v6, when using `npm run hot`, bundled files are not written into public folder but are still served correctly
See original GitHub issue- Laravel Mix Version: 6.0.9 (
npm list --depth=0) - Node Version (
node -v): 12.20.0 - NPM Version (
npm -v): 6.14.9 - OS: Windows 10
Context:
I have a blade component that automatically injects scripts and styles by name when called:
{{-- asset-injector.blade.php --}}
@props(['name' => ''])
@if(isset($name) && !empty($name))
@if (file_exists(public_path("js/$name.js")))
@push('scripts')
<script src="{{ mix("js/$name.js") }}" defer></script>
@endpush
@endif
@if (file_exists(public_path("css/$name.css")))
@push('styles')
<link rel="stylesheet" href="{{ mix("css/$name.css") }}">
@endpush
@endif
@endif
{{-- example.blade.php --}}
<div class="any-component>
@once
{{-- Automatically injects corresponding "example.js" and "example.css" if exists --}}
<x-asset-injector name="example" />
@endonce
</div>
Description:
Just upgraded to version 6 from version 5.
In version 5, when I run npm run hot, bundled files will be written into public folder (or whatever folder set by mix.setPublicPath).
That is not the case anymore in version 6.
In version 6, when I run npm run hot, the files are bundled, but are not being written into the public folder.
The files are still served correctly with mix('path/to/file'). The problem is that it is not writing into public folder anymore, so that the file_exists() call in the component shown above will always be false when in hot reloading mode.
This only happens in npm run hot. When running dev, watch, and prod, the files are created and written correctly into public folder.
Question
Is this behaviour a bug or by design? If it is by design, why are we doing this and where have the bundled files gone and being served from?
Steps To Reproduce:
Run npm run hot and observe bundled files will not be created/written into public path but are still served correctly.
Issue Analytics
- State:
- Created 3 years ago
- Comments:5

Top Related StackOverflow Question
Ah sorry, the webpack documentation hasn’t been updated for webpack dev server v4 configuration.
The correct version is:
All webpack-dev-middleware compatible configuration was removed in favor of passing it via the
devoption.@thecrypticace ah I see. It works now, thank you!