diff --git a/client/src/templates/Challenges/utils/build.js b/client/src/templates/Challenges/utils/build.js index 62507a5f94..c07a0f5001 100644 --- a/client/src/templates/Challenges/utils/build.js +++ b/client/src/templates/Challenges/utils/build.js @@ -48,10 +48,19 @@ const composeFunctions = (...fns) => fns.map(applyFunction).reduce((f, g) => x => f(x).then(g)); function buildSourceMap(files) { - return files.reduce((sources, file) => { - sources[file.name] = file.source || file.contents; - return sources; - }, {}); + // TODO: concatenating the source/contents is a quick hack for multi-file + // editing. It is used because all the files (js, html and css) end up with + // the same name 'index'. This made the last file the only file to appear in + // sources. + // A better solution is to store and handle them separately. Perhaps never + // setting the name to 'index'. + return files.reduce( + (sources, file) => { + sources[file.name] += file.source || file.contents; + return sources; + }, + { index: '' } + ); } function checkFilesErrors(files) {