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

killerbeast2017's avatar

Webpack config for AngularJS in Laravel

I am trying to create an Angular/Laravel web application(first time with both combined). I created a Laravel 5.4 application and make some apis for login/signup/logout using JWT auth. I installed bower globally and created a bower project inside the resources/assets. I implemented the layout, router and controllers in angular. Now I want to use webpack to transpile the code to es5 and render a single js file inside public folder. How do I need to tweak my webpack to do this?

My current directory structure looks like this: https://ibb.co/daZY0a

0 likes
7 replies
WebKenth's avatar
WebKenth
Best Answer
Level 16

Wouldn't Laravel Mix just work out of the box? if you are referencing app.js in the mix file you should be able to run it and be done?

1 like
killerbeast2017's avatar

@WebKenth Yeah, completely forgot that. Got the file bundled now. Thanks! But another major question: inside the resources/assets, if you have seen my screenshot there are few html files are there how does that get to the view? I mean like I never used Angular & Laravel together so dont have much of an idea. Should I move the html files to the resources/views folder and use my routes to render that view or how does it work?

WebKenth's avatar

Depends on what you want to use Laravel Blade for.

I would keep it together since you have gone with Angular.

Any particular reason you are using Angular?

are you planning on using Angular to control the routes and serve HTML files? or are you planning on "injecting" angular into your blade files ?

1 like
killerbeast2017's avatar

@WebKenth I would prefer to use angular routes to serve html files. So how does it need to be configured to use angular routes?

killerbeast2017's avatar

@WebKenth How can we render the html files made using angular? Or should we use the angular router to serve html files?

WebKenth's avatar

No Idea, i am not an angular guy i prefer Vue ;)

Please or to participate in this conversation.