Chirag Chaudhari
Chirag Chaudhari

Reputation: 1817

How should I include the files generated by laravel mix in my scripts and styles?

As I run "npm run production" mix generates minified files and saves them in specific directory. But how can I include them in my scripts and styles as the default name of the file is app.js and the one generated by mix is that it appends some charecter in name. mix generated app.js vue file

and in my blade file I have included in following way: enter image description here

I am stuck at this as I wanted this inclusion process to be dynamic. Please suggest the approaches in which I can do it.

Upvotes: 2

Views: 469

Answers (1)

Alexey Mezenin
Alexey Mezenin

Reputation: 163748

Use the mix() helper. From the docs:

After generating the versioned file, you won't know the exact file name. So, you should use Laravel's global mix function within your views to load the appropriately hashed asset. The mix function will automatically determine the current name of the hashed file:

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

Upvotes: 4

Related Questions