diff --git a/build/build-svgs.js b/build/build-svgs.js index 33ae82ed32..625083c3a7 100644 --- a/build/build-svgs.js +++ b/build/build-svgs.js @@ -13,9 +13,6 @@ const iconsDir = path.join(__dirname, '../icons/') const svgAttributes = { class: '', - width: '1em', - height: '1em', - viewBox: '0 0 16 16', fill: 'currentColor', xmlns: 'http://www.w3.org/2000/svg' } @@ -53,6 +50,16 @@ const processFile = (file, config) => new Promise((resolve, reject) => { $(svg).attr(attr, val) } + const dimensions = $(svg).attr('viewBox').split(' ') + const svgWidth = dimensions[2] + const svgHeight = dimensions[3] + + const svgWidthEm = svgWidth / 16 + const svgHeightEm = svgHeight / 16 + + $(svg).attr('width', svgWidthEm + 'em') + $(svg).attr('height', svgHeightEm + 'em') + $(svg).attr('class', `bi bi-${path.basename(file, '.svg')}`) fs.writeFile(file, $(svg), 'utf8')