import history from '!json!../assets/data/history.json'
import metadata from '!json!../assets/data/metadata.json'
// Loading latest season in the main bundle itself
import latestSeasonData from '!json!../assets/data/season-latest.json'

const seasonDataCtx = require.context(
  'file-loader!../assets/data/',
  false,
  /^\.\/.*\.json$/
)

const distDataCtx = require.context(
  'file-loader!../assets/data/distributions/',
  false,
  /^\.\/.*\.json$/
)

const seasonDataUrls = seasonDataCtx.keys().reduce((acc, key) => {
  if (key.startsWith('./season-')) {
    // Identifier is like '2013-2014'
    acc[key.slice(9, -5)] = seasonDataCtx(key)
  }
  return acc
}, {})

const distDataUrls = distDataCtx.keys().reduce((acc, key) => {
  if (key.startsWith('./season-')) {
    // Identifier is like '2013-2014-hhs10'
    acc[key.slice(9, -5)] = distDataCtx(key)
  }
  return acc
}, {})

export { seasonDataUrls, distDataUrls, latestSeasonData, history, metadata }

@@ -228,16 +228,103 @@
 st.json'
+%0Aimport latestDistData from '!json!../assets/data/distributions/season-latest-nat.json'
 %0A%0Aconst 
@@ -1019,16 +1019,32 @@
 sonData,
+ latestDistData,
  history

Load latestDistData in main build