Web Dev Solutions

Catalin Mititiuc

aboutsummaryrefslogtreecommitdiff
blob: aba29d2d14393c833caddbbc6f06066437418030 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import mapsheets from './assets/images/mapsheets.svg';
import counters from './assets/images/counters.svg';

const files = {
  'mapsheets.svg': mapsheets,
  'counters.svg': counters
}

document.querySelectorAll('use[data-href*=".svg"').forEach(el => {
  const [filename] = el.dataset.href.match(/.+\.svg/g)
    , href = el.dataset.href.replace(filename, files[filename].split('/').pop())
    ;

  el.setAttributeNS(null, 'href', href);
});