UNPKG

scoped-rem-loader

Version:

Webpack loader of scoped-rem, a tool that makes CSS rem units relative to a custom root font size.

23 lines (21 loc) 931 B
import { parseQueryOptions, transformCss } from "scoped-rem"; //#region src/index.ts const scopedRemLoader = function(source) { const resourceQuery = this.resourceQuery || ""; if (!resourceQuery || !resourceQuery.startsWith("?")) return source; const queryString = resourceQuery.slice(1); try { const options = parseQueryOptions(queryString); if (!options) return source; const filename = this.resourcePath; if (!filename) throw new Error("[scoped-rem-loader] Missing resource path"); return transformCss(typeof source === "string" ? source : source.toString("utf-8"), filename, options); } catch (error) { this.emitError(/* @__PURE__ */ new Error(`[scoped-rem-loader] Failed to transform ${this.resourcePath}: ${error instanceof Error ? error.message : String(error)}`)); return source; } }; var src_default = scopedRemLoader; //#endregion export { src_default as default }; //# sourceMappingURL=index.js.map