fix: explicit import paths for collectstatic hashes

This commit is contained in:
David Larlet 2024-06-14 17:20:16 -04:00
parent 6de3e1f881
commit ceab5090a7
No known key found for this signature in database
GPG key ID: 3E2953A359E7E7BD

View file

@ -55,10 +55,25 @@ export default class Importer {
}
loadImporters() {
for (const key of Object.keys(this.map.options.importers || {})) {
import(`./importers/${key}.js`).then((mod) => {
this.IMPORTERS.push(new mod.Importer(this.map, this.map.options.importers[key]))
})
for (const [name, config] of Object.entries(this.map.options.importers || {})) {
const register = (mod) => {
this.IMPORTERS.push(new mod.Importer(this.map, config))
}
// We need to have explicit static paths for Django's collectstatic with hashes.
switch (name) {
case 'geodatamine':
import('./importers/geodatamine.js').then(register)
break
case 'communesfr':
import('./importers/communesfr.js').then(register)
break
case 'overpass':
import('./importers/overpass.js').then(register)
break
case 'datasets':
import('./importers/datasets.js').then(register)
break
}
}
}