src/vs/css.build.ts/rewriteOrInlineUrls
function rewriteOrInlineUrls(originalFileFSPath: string, originalFile: string, newFile: string, contents: string, forceBase64: boolean, inlineByteLimit: number): string {
	if (!fs || !path) {
		throw new Error(`Cannot rewrite or inline urls without 'fs' or 'path'!`);
	}
	return CSSPluginUtilities.replaceURL(contents, (url) => {
		if (/\.(svg|png)$/.test(url)) {
			const fsPath = path.join(path.dirname(originalFileFSPath), url);
			const fileContents = fs.readFileSync(fsPath);

			if (fileContents.length < inlineByteLimit) {
				const normalizedFSPath = fsPath.replace(/\\/g, '/');
				inlinedResources.push(normalizedFSPath);

				const MIME = /\.svg$/.test(url) ? 'image/svg+xml' : 'image/png';
				let DATA = ';base64,' + fileContents.toString('base64');

				if (!forceBase64 && /\.svg$/.test(url)) {
					// .svg => url encode as explained at https://codepen.io/tigt/post/optimizing-svgs-in-data-uris
					const newText = fileContents.toString()
						.replace(/"/g, '\'')
						.replace(/%/g, '%25')
						.replace(/</g, '%3C')
						.replace(/>/g, '%3E')
						.replace(/&/g, '%26')
						.replace(/#/g, '%23')
						.replace(/\s+/g, ' ');
					const encodedData = ',' + newText;
					if (encodedData.length < DATA.length) {
						DATA = encodedData;
					}
				}
				return '"data:' + MIME + DATA + '"';
			}
		}

		const absoluteUrl = CSSPluginUtilities.joinPaths(CSSPluginUtilities.pathOf(originalFile), url);
		return CSSPluginUtilities.relativePath(newFile, absoluteUrl);
	});
}