You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

15 lines
370 B

const loaderUtils = require('loader-utils')
module.exports = function (source) {
const matchPXExp = /([0-9.]+px)/g
const retina = loaderUtils.getOptions(this)?.retina
if (!retina) {
return source
}
return source.replace(matchPXExp, (_match, m1) => {
const pixels = Number(m1.slice(0, m1.length - 2))
return (pixels / 1080) * 100 + 'vmin'
})
}