sergiz
2 months ago
269
5
Mix

Multiple JS files per page

Posted 2 months ago by sergiz

Hello.

I'm not sure how to handle the following situation using Laravel Mix/Webpack. Let's say my app has some JS code that is needed in every page (that extends layour.blade.php) and then every page has some of its own JS. Besides that I have some JS code that is shared between other JS files.

Overview:

layout.js (included in layout.blade.php)

pagea.js (included in pagea.blade.php that extends from layout.blade.php)

pageb.js (included in pageb.blade.php that extends from layout.blade.php)

common.js (some functions that are needed in pagea.js and pageb.js)

pagec.js (included in pagec.blade.php that extends from layout.blade.php, but doesn't need common,js code)

and then pageb.js and pagec.js also need the lodash module

How do I handle this in an optimal way?

Please sign in or create an account to participate in this conversation.