Skip to content

Commit

Permalink
fix(global resource): load resources other than .ts or .js
Browse files Browse the repository at this point in the history
  • Loading branch information
ahmedshuhel committed Mar 25, 2016
1 parent c179a3e commit b57f290
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions src/framework-configuration.js
Expand Up @@ -64,14 +64,41 @@ function loadResources(aurelia, resourcesToLoad, appResources) {
});

function _normalize(load) {
return aurelia.loader.normalize(load.moduleId, load.relativeTo)
let moduleId = load.moduleId;
let ext = getExt(moduleId);

if(isOtherResource(moduleId)) {
moduleId = removeExt(moduleId);
}

return aurelia.loader.normalize(moduleId, load.relativeTo)
.then(normalized => {
return {
name: load.moduleId,
importId: normalized
importId: isOtherResource(load.moduleId) ? addOriginalExt(normalized, ext) : normalized
};
});
}

function isOtherResource(name) {
let ext = getExt(name);
if(!ext) return false;
if(ext === '') return false;
if(ext === '.js' || ext === '.ts') return false;
return true;
}

function removeExt(name) {
return name.replace(/\.[^/.]+$/, "");
}

function getExt(name) {
return name.split('.')[1];
}

function addOriginalExt(normalized, ext) {
return removeExt(normalized) + '.' + ext;
}
}

function assertProcessed(plugins) {
Expand Down

0 comments on commit b57f290

Please sign in to comment.