vike
Version:
The Framework *You* Control - Next.js & Nuxt alternative for unprecedented flexibility and dependability.
11 lines (10 loc) • 503 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.applyRegExpWithMagicString = applyRegExpWithMagicString;
function applyRegExpWithMagicString(magicString, regExp, replacement) {
const envStatementRegEx = typeof regExp === 'string' ? new RegExp(regExp, 'g') : regExp;
let match;
while ((match = envStatementRegEx.exec(magicString.original))) {
magicString.overwrite(match.index, match.index + match[0].length, JSON.stringify(replacement));
}
}