Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ymhtut's avatar

How do you manage your assets?

I am new to Laravel and need some suggestions for managing assets.

I put my unminified css files and js files under public/css and public/js and access them from blade with asset(). So, I am having trouble in compiling these assets with mix and switching from production to development mode.

Is putting unminified css and js files under public folder a bad practice?

If I put them under resources/assets, do I have to minify them every time before I test the application?

What is the best way of doing this?

Thanks in advanced!

0 likes
4 replies
bobbybouwmann's avatar
Level 88

That's an excellent question!

For development purposes you don't have to run the production mode of compiling assets. This is actually useful when you develop and have your develop tools open in the browser. When it's not minified you can easily inspect the code and see what it's doing. You can even debug your javascript!

Now to have everything compiled with production mode on production you have two options.

  1. Run npn run production once and push that to your repository. From there you can deploy that to your server. However when you forget to run this once you will end up with unminified files on your server. So this would be a step before you go to production.
  2. Run npm run production during deployment. For example when you have deployments with deployer or forge you can run commands before you put the application online. It's a good practice to do this, since you don't have these files in your project or git control. That also means no more conflicts when you work with others and need to compile things all the time. Note that you need to run npm on your production server so you also need to install that.

Conclusion: Option 1 works best for you when you work alone. When you work with others option 2 in the best!

Let me know if you have any more questions ;)

1 like
Cronix's avatar

If he is using mix then he should be using mix() instead of asset() to load assets. Otherwise the file versioning/cache busting won't work.

Please or to participate in this conversation.