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 * 2 + 'px' }) }