I have a jhipster generated gateway app. I have jquery plugin added to in webpack.dev.js
There is one scripts.js which stays in assets folder , I have included that script by adding its entry in vendor.ts. and now I can see that its in bundled in main.bundle.js
The content of that script is :
jQuery.widget.bridge('uibutton', jQuery.ui.button);
//receive calls from typescript code to update the layouts
var AdminLTE = (function() {
return {
init: function() {
jQuery(function(){
jQuery.AdminLTE.layout.activate();
jQuery.AdminLTE.layout.fix();
jQuery.AdminLTE.layout.fixSidebar();
});
}
}
})(AdminLTE||{});
and in my component.ts, I have code like this :
declare var AdminLTE: any;
export class AdminDashboard1Component implements OnInit {
------------
ngOnInit() {
// Update the AdminLTE layouts
AdminLTE.init();
----------
}
When I load the app, the breakpoints gets hit at line 1 of scripts.js and complaints
Cannot read property 'bridge' of undefined
where our jQuery works at other places in the app.
If I comment this line, and let the app go ahead, it halts at AdminLTE.init() in component.ts, where it complains
variable AdminLTE not found.
This is not an answer but more of a suggestion and hint on how this should be done properly in any webpack based setup(not just with JHipster)
I have used AdminLTE in the past btw.
In a webpack based workflow similar to the one JHipster provides(it's not special it's quite similar to what most tools like Angular CLI etc provide) you need to keep few things in mind when trying to use external libraries
The configuration is geared to work with a package manager like NPM so when you add something via NPM it mostly works out of the box and in some rare cases you might have to configure a rule to say expose a global variable etc, like the JQuery one for example)
If you add scripts in assets etc, you need to import it properly and setup rules to process those properly, by default webpack wouldn't expect scripts in assets, scripts should be under the configured script root
In the JHipster setup, we support JQuery as there might be rare cases when it is needed but it is generally not a good idea to mix Angular and Jquery together as you will be asking for glitches and trouble as both will try to manage DOM. In your case, you are expecting AdminLTE plugin to be loaded when you run your app but webpack doesn't know of those plugins as you haven't setup a way for webpack to load them and you haven't imported them probably as well. But then I wouldnt know for sure as you dont give enough info on what exactly you are doing.
So the proper way to do this would be to install adminLTE using
npm install admin-lte --saveand then add your scripts in thewebapp/appfolder and import them appropriately. you might or might not have to tewak webpack loader to load adminLTE after jqueryIdeally you should be asking AdminLTE people on how to use it with Angular