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

double-a's avatar

Bundle Laravel Package's Js/Css alongside the Application

Hi everybody,

we are working on a medium sized project and decided to split it up to smaller packages and use them in a core application as it is easier to work on it in multiple teams, the problem is the control panel is a VueJs SPA and each package needs to add it's own pages to control panel.

as i was reading the documentation the only way mentioned is to publish them to public folder, but because we are using vue router this approach is not viable.

is there any way to publish these assets to resources/js and resources/css ?? somehow require them in the main js/css ??

or any other way that can solve this problem.

0 likes
2 replies
devingray_'s avatar

I don't quite understand?

You want to have one app.js (with vue router) and then use other js files that still work within that file that has the router?

EG:

js/app.js and css/app.css => Base application with router

--

js/team1.js and css/team1.css => Team 1

js/team2.js and css/team2.css =>Team 2

--

I think if these teams are creating router pages, this is way more difficult than just splitting the code in folders and compiling all into same files.

double-a's avatar

I think I found the soution but Let me explain more,

The Base application resource folder has a structure like this

  • js/
    • vendor/
      • base/
        • route.js
      • package_name/
        • routes.js
        • components/
        • pages/
    • router.js
    • pages/
    • components/

the vendor/package_name/routes.js is actually a dictionary of routes. the router.js is discovering whatever routes is in vendor folder, merge them together and feed it to Vue Router.

this gives us enough flexibility so each team can have as many component or pages as they want and just feed the base app with a dictionary to work with.

the main problem was the js/css files lives in the Laravel Package, i read the documentation for publishing assets and i missed the section for resource_path() function .

i think i can publish my assests like this

public function boot()
{
    $this->publishes([
        __DIR__.'/../resources/js' => resource_path('js/vendor/package_name'),
    ]);
}

and same way for css

if you see any problem with this approach please let me know. thanks

Please or to participate in this conversation.