const SUPPORTED_PREPROCESSORS = new Set(["scss", "sass", "styl", "stylus", "less"]);
function getViteTransform(viteConfig) {
  const viteCSSPlugin = viteConfig.plugins.find(({name}) => name === "vite:css");
  if (!viteCSSPlugin)
    throw new Error(`vite:css plugin couldn\u2019t be found`);
  if (!viteCSSPlugin.transform)
    throw new Error(`vite:css has no transform() hook`);
  return viteCSSPlugin.transform.bind(null);
}
async function transformWithVite(value, attrs, id, transformHook) {
  const lang = (attrs.lang || "").toLowerCase();
  if (!SUPPORTED_PREPROCESSORS.has(lang))
    return null;
  const result = await transformHook(value, id.replace(/\.astro$/, `.${lang}`));
  return result || null;
}
export {
  getViteTransform,
  transformWithVite
};
//# sourceMappingURL=data:application/json;base64,ewogICJ2ZXJzaW9uIjogMywKICAic291cmNlcyI6IFsiLi4vLi4vc3JjL3ZpdGUtcGx1Z2luLWFzdHJvL3N0eWxlcy50cyJdLAogICJtYXBwaW5ncyI6ICJBQUtBLE1BQU0sMEJBQTBCLElBQUksSUFBSSxDQUFDLFFBQVEsUUFBUSxRQUFRLFVBQVU7QUFHcEUsMEJBQTBCLFlBQWdEO0FBQy9FLFFBQU0sZ0JBQWdCLFdBQVcsUUFBUSxLQUFLLENBQUMsQ0FBRSxVQUFXLFNBQVM7QUFDckUsTUFBSSxDQUFDO0FBQWUsVUFBTSxJQUFJLE1BQU07QUFDcEMsTUFBSSxDQUFDLGNBQWM7QUFBVyxVQUFNLElBQUksTUFBTTtBQUM5QyxTQUFPLGNBQWMsVUFBVSxLQUFLO0FBQUE7QUFJdEMsaUNBQXdDLE9BQWUsT0FBK0IsSUFBWSxlQUFvRTtBQUNwSyxRQUFNLE9BQVEsT0FBTSxRQUFRLElBQUk7QUFDaEMsTUFBSSxDQUFDLHdCQUF3QixJQUFJO0FBQU8sV0FBTztBQUMvQyxRQUFNLFNBQVMsTUFBTSxjQUFjLE9BQU8sR0FBRyxRQUFRLFlBQVksSUFBSTtBQUNyRSxTQUFPLFVBQVU7QUFBQTsiLAogICJuYW1lcyI6IFtdCn0K
