I'm trying to migrate from grails 2 to grails 3 so I have to use asset-pipeline plugin to manage my java script files. The problem is that I use couple of external libraries eg globalize, ajax-solr.They are quite big and have multiple files which depend one on each other. They also have a lot of dependencies to jquery and use namespaces a lot. So, when I simply copy them into asset/javascript
I get a lot of exceptions in the console eg
Uncaught ReferenceError: AjaxSolr is not defined
Uncaught ReferenceError: jQuery is not defined
ParameterHashStore.js:13 Uncaught TypeError: Cannot read property 'extend' of undefined
The first question is where those libaries should be placed? in asset/javascript
in subfolders? Or in asset/lib
as the documentation suggests? (A common folder that gets added to this set of organization is a "lib" folder. This folder can be useful in organizing third party libraries like jQuery, or Bootstrap. - http://www.asset-pipeline.com/manual/ ). If yes, how to force asset plugin to pick it up from there?
The second how to resolve the issues with dependencies? Should I modify globalize and ajax-solr files with //= require
directive?
I managed to make it work. I placed globalize in lib
folder ( grails-app/assets/lib/globalize/
) and created a file globalize-manifest.js
with all the imports:
//= require globalize/lib/globalize
//= require globalize/lib/cultures/globalize.culture.pl-PL.js
...
then when I need to use globalize I import it using
// require globalize-manifest
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.