Shivamyadav's avatar

How to load the angular js version 2 from the laravel vite instead of the mix?

I have setup the vite and removed the mix and scss is loading and working with the laravel but the angular js version 2 is breaking.   How can i setup the order as it is and avoid any siteApp issue form the angular itself this is how it was setup form the webpack.

0 likes
3 replies
imrandevbd's avatar

The issue here is that Vite treats assets as ES modules by default, whereas your current legacy setup relies on strict, sequential concatenation (mix.babel) where jQuery, Angular, and all those plugins register themselves globally on the window object. If Vite processes them, they run in their own module scopes, breaking dependencies like angular or siteApp because jQuery plugins can't find jQuery, and Angular plugins can't find angular.

Since you have a massive list of legacy jQuery and AngularJS v1/v2 vendors, trying to import them properly via ES modules will be an endless rabbit hole of configuration headaches.

The cleanest solution is to let Vite handle your modern code (like your Sass/CSS), but use Vite's build.rollupOptions to keep bundling these legacy assets into flat files, while forcing them to remain global scripts.

1 like
Shivamyadav's avatar

Thanks for the suggestion man, I will give it a try and let you know if this was able to setup or not.

Shivamyadav's avatar

My rollup options form the vite config file

Even I am getting the errors like :

siteApp is not defined $(...).select2 is not a function

$(...).slick is not a function

$ jquery and sometimes angular

Please or to participate in this conversation.