Files
authentik/web/bundler/css-assets-plugin/node.js
T
Teffen Ellis f00772faf1 web: Font fixes (#15581)
* add base element

Signed-off-by: Jens Langhammer <jens@goauthentik.io>

* web: Rewrite relative CSS asset paths. Update fonts.

Update web/bundler/css-assets-plugin/node.js

Signed-off-by: Teffen Ellis <592134+GirlBossRush@users.noreply.github.com>

---------

Signed-off-by: Jens Langhammer <jens@goauthentik.io>
Signed-off-by: Teffen Ellis <592134+GirlBossRush@users.noreply.github.com>
Co-authored-by: Jens Langhammer <jens@goauthentik.io>
2025-07-24 15:40:38 +00:00

31 lines
778 B
JavaScript

/**
* @file CSS asset rewrite plugin for ESBuild.
*
* @import { Plugin } from "esbuild"
*/
import * as fs from "node:fs/promises";
/**
* Rewrite `url()` calls in CSS files to point to the static directory.
*
* @returns {Plugin}
*/
export function cssAssetPlugin() {
return {
name: "css-text-loader",
setup: (build) => {
const URLPattern = /url\(\s*['"]?(?:[./]*)(assets\/[^)'"']*)['"]?\s*\)/g;
build.onLoad({ filter: /\.css$/ }, async (args) => {
const contents = await fs.readFile(args.path, "utf8");
return {
loader: "text",
contents: contents.replaceAll(URLPattern, "url(./static/dist/$1)"),
};
});
},
};
}