-
Notifications
You must be signed in to change notification settings - Fork 4
/
importAddons.js
70 lines (41 loc) · 1.7 KB
/
importAddons.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
//TODO: Import css files ¿pasar los import al html raiz ?
//Array de paths a los asset-manifest.json de cada addon
// const Addons = ['addons/tree_view/build/asset-manifest.json']
// const Addons = ['addons/tree_view/build', 'addons/gamification/build']
const Addons = ['kalenis_views/tree_view/build']
var readAddons = async function(){
Addons.map(async function(path){
fetch(path+'/asset-manifest.json')
.then(response => {
return response.json()
})
.then(data => {
Object.values(data.files).map(async function(file){
if(file.endsWith('.css')===true){
//adding css style for production
var new_css = $('<link rel="stylesheet" type="text/css" />')
new_css.attr('href', file)
var new_css = $('head').append(new_css)
return true
}
if(file.endsWith('.js')===false ){
return true
}
var moduleSpecifier;
if(file.startsWith('kalenis_views')){
//Prod Build
moduleSpecifier= '/'+file
}
else{
//dev Build
moduleSpecifier = '/'+path+file
}
//cra watch
// const moduleSpecifier = '/'+path+file
//Prod build
// const moduleSpecifier = '/'+file
await import(moduleSpecifier)
})
})
})
}()