mirror of
https://github.com/goauthentik/authentik.git
synced 2026-06-17 19:09:11 +03:00
f00772faf1
* 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>
31 lines
778 B
JavaScript
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)"),
|
|
};
|
|
});
|
|
},
|
|
};
|
|
}
|