Search code examples
javascriptlaravelvue.jsversioning

Laravel - app.jss and CSS files versionning


I am trying to add files versions so that I don't need to force refresh with ctrl F5 at each change.

Here is how everything is added:

in template.blade.php

<script src="../js/app.js"></script>
<link rel="stylesheet" href="/css/composants.css">

webpack.mix.js

mix.js('resources/js/app.js', 'public/js');

Here is what I tried

mix.js('resources/js/app.js', 'public/js'), 'public/css');

if (mix.inProduction()) {
    mix.version();
}


 <script src="{{ mix('../js/app.js') }}"></script>

But I get this error

Unable to locate Mix file: /../js/app.js. (View: C:\laragon\www\projet\resources\views\template.blade.php) (View: C:\laragon\www\projet\resources\views\template.blade.php)

Thanks a lot for your help, I am a bit lost here.


Solution

  • If you are using mix() then you have to provide relative path to pubilc. So use mix('js/app.js'). More details here https://laravel.com/docs/5.8/helpers#method-mix