Closed StErMi closed 5 years ago
You should be able to provide a resources
configuration which maps the script in node_modules/qrcode-generator/qrcode.js
to the namespace of your library: it/designfuture/qrcode/3rdparty
, like this:
openui5_preload: {
library: {
options: {
resources: [
{ cwd: '<%= dir.src %>' },
{
cwd: 'node_modules/qrcode-generator',
src: 'qrcode.js',
prefix: 'it/designfuture/qrcode/3rdparty'
}
],
dest: '<%= dir.dest %>',
compatVersion: '1.44',
compress: false
},
libraries: 'it/designfuture/qrcode'
}
}
This will include the script into your library-preload.js
, as from the namespace (it/designfuture/qrcode/3rdparty/qrcode.js
) it is part of it, although it's physically at a different location on your hard drive (node_modules/qrcode-generator/qrcode.js
).
In your code you can load that script like any other module, by providing the namespace of it (it/designfuture/qrcode/3rdparty/qrcode
). Note that currently the return value of such thirdparty module is not available in the sap.ui.define/require
callback, so you need to use the global variables defined by the thirdparty scripts. In your case it would be qrcode
.
Hope this helps 👍
@matz3 I solved the issue, thank you very much for your help. You can checkout the updated repo: https://github.com/StErMi/openui5-qrcode
Now as I said I've to solve other issue:
@StErMi I guess this can be closed, as you switch to the UI5 Tooling.
Hi, I'm trying to include external files from my node_modules to build the library-preload.js My actual Gruntfile.js is like this:
it get aborted with this error:
Is there a way to do what I want to achieve?