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

Dev4's avatar
Level 1

How to build assets in a modular structure

I need some advice on best practices for assets management on a large Laravel 10 project using Vite. In the resources directory I have structured my assets logically by "module" i.e.

  • resources
    • assets
      • foo-module
        • css
          • a.css
          • b.css
        • js
          • x.js
          • y.js
      • bar-module
        • css
          • a.css
          • b.css
        • js
          • x.js
          • y.js
    • views

I want Vite to build and write these assets to the "public/assets" directory using the exact same directory structure as above.

I've tried a few methods and came close, the .js files are written to "public/build/assets/foo/* etc., but not the .css files, they are always written to "public/build/" only.

What is the most-used, best approach for managing/organising large assets in Laravel?

How do you change the default output directory from "public/build" to "public/assets"?

If my approach is correct, please assist me in solving this problem with Vite.

Thanks.

0 likes
0 replies

Please or to participate in this conversation.