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

14 lines
396 B
JavaScript

5 years ago
"use strict";
const rewriteCssUrlsLib = require("rewrite-css-urls");
module.exports = function rewriteCssUrls(css, rewriteUrl) {
let rewritten1 = rewriteCssUrlsLib.findAndReplace(css, { replaceUrl: (ref) => rewriteUrl(ref.url) });
let rewritten2 = rewritten1.replace(/sourceMappingURL=([^ ]+)/, (_match, url) => {
return `sourceMappingURL=${rewriteUrl(url)}`;
});
return rewritten2;
};