I am creating a package for ExtJS 6 where I need to include an external JavaScript file as a resource.
I placed the file in the resources
folder of my package, but I can't seem to find any documentation on how to use Ext.require()
to load this file.
I could use Ext.require(Ext.resolveResource("<@MyPackage>custom")
- that downloads and executes the Sencha/build/production/MyApp/classic/resources/MyPackage/custom.js
but it also plains that it cannot load the class from this file:
[E] [Loader] The following classes failed to load:
[E] [Loader] Sencha/build/production/MyApp/classic/resources/MyPackage/custom from Sencha/build/production/MyApp/classic/resources/MyPackage/custom.js
Can Ext.require()
be used for this purpose or do I have to use Ext.AJAX
and create the <script>
tag by myself?
I am creating a package for ExtJS 6 where I need to include an external JavaScript file as a resource.
I placed the file in the resources
folder of my package, but I can't seem to find any documentation on how to use Ext.require()
to load this file.
I could use Ext.require(Ext.resolveResource("<@MyPackage>custom")
- that downloads and executes the Sencha/build/production/MyApp/classic/resources/MyPackage/custom.js
but it also plains that it cannot load the class from this file:
[E] [Loader] The following classes failed to load:
[E] [Loader] Sencha/build/production/MyApp/classic/resources/MyPackage/custom from Sencha/build/production/MyApp/classic/resources/MyPackage/custom.js
Can Ext.require()
be used for this purpose or do I have to use Ext.AJAX
and create the <script>
tag by myself?
- Have you tried edition app.json? – Dumbledore Commented Jan 26, 2016 at 13:31
- Since I am creating a package, editing app.json seems wrong as it is outside the package code. – Knaģis Commented Jan 26, 2016 at 13:32
- Are you creating a new class or overriding existing classes? – Dumbledore Commented Jan 26, 2016 at 13:34
- new ponents that extend Ext.Component. – Knaģis Commented Jan 26, 2016 at 14:11
-
IMO, you need to add the files as resource in app.json (after the ExtJS bundle, of course), so that you ExtJS can load you package at app start and you can use these class just like an existing class. Second option is that you can use
Ext.Loader
. However, I'd like to know other people's thoughts/opinions as well. – Dumbledore Commented Jan 26, 2016 at 15:37
2 Answers
Reset to default 2Edit app.json and look for js property or add it in case it is not there.
...
"js": [
{
"path": "lib/myExternalLibrary.js",
"includeInBundle": true
},
]
...
reference https://docs.sencha./cmd/6.x/microloader.html#js
Maybe its already to late, but this works for ExtJs6 in your package.json
"js" : [{
"path": "resources/js/OpenLayers.js",
"bundle": true
}]