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

lepev's avatar
Level 2

How to manage, build and deploy frontend assets and js in Laravel packages

Hi guys,

I have multiple packages to build for a big application we are working on and I'm wondering how I will deal with frontend dependancies (js packages, images/fonts, sass).

Currently I have package.json in my root package folder with all dependencies for that package, and I have postinstall script in my main package.json to scan all subfolders of the packagesfolder to run npm install when necessary.

But how I do I build/deploy those assets?

0 likes
3 replies
martinbean's avatar

@pvledoux You define your application’s dependencies in your package.json file. When deploying, run npm run prod to build your assets and include the generated files in your deployment (but ignore them from your source control repository).

martinbean's avatar

@pvledoux Packages should provide a “dist” (compiled) version of its assets, that you bundle in your “parent” application. You could maybe set up a pre-commit hook in your package directories that automatically compiles and adds those compiled versions to the commit.

Please or to participate in this conversation.