2024-09-26 13:06:32 +00:00
|
|
|
import terser from "@rollup/plugin-terser";
|
2022-01-13 07:28:30 +00:00
|
|
|
import path from "node:path";
|
|
|
|
import type { OutputOptions, RollupOptions } from "rollup";
|
|
|
|
import { defineConfig } from "rollup";
|
|
|
|
|
|
|
|
interface DefineOptionsArgs {
|
|
|
|
file: string;
|
|
|
|
name: string;
|
|
|
|
amdId: string;
|
|
|
|
}
|
|
|
|
|
2024-09-26 13:06:32 +00:00
|
|
|
const sourceFile = (file: string) => path.join("src", file);
|
|
|
|
const targetFile = (file: string) => path.join("dist", file);
|
|
|
|
|
2022-01-13 07:28:30 +00:00
|
|
|
function defineOptions({
|
|
|
|
file,
|
|
|
|
name,
|
|
|
|
amdId,
|
|
|
|
}: DefineOptionsArgs): RollupOptions[] {
|
2024-09-26 13:06:32 +00:00
|
|
|
const input = sourceFile(`${file}.js`);
|
2022-01-13 07:28:30 +00:00
|
|
|
const umdOutput: OutputOptions = {
|
|
|
|
format: "umd",
|
|
|
|
name,
|
|
|
|
amd: { id: amdId },
|
|
|
|
};
|
|
|
|
|
|
|
|
return [
|
2024-09-26 13:06:32 +00:00
|
|
|
// Modern ES module variant.
|
2022-01-13 07:28:30 +00:00
|
|
|
{
|
2024-09-26 13:06:32 +00:00
|
|
|
input,
|
2022-01-13 07:28:30 +00:00
|
|
|
output: [
|
|
|
|
{
|
2024-09-26 13:06:32 +00:00
|
|
|
file: targetFile(`${file}.mjs`),
|
2022-01-13 07:28:30 +00:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
2024-09-26 13:06:32 +00:00
|
|
|
// Legacy Universal Module Definition, or “UMD”.
|
2022-01-13 07:28:30 +00:00
|
|
|
{
|
2024-09-26 13:06:32 +00:00
|
|
|
input,
|
2022-01-13 07:28:30 +00:00
|
|
|
output: [
|
|
|
|
{
|
|
|
|
...umdOutput,
|
2024-09-26 13:06:32 +00:00
|
|
|
file: targetFile(`${file}.js`),
|
2022-01-13 07:28:30 +00:00
|
|
|
},
|
|
|
|
{
|
|
|
|
...umdOutput,
|
2024-09-26 13:06:32 +00:00
|
|
|
file: targetFile(`${file}.min.js`),
|
2022-01-13 07:28:30 +00:00
|
|
|
sourcemap: true,
|
|
|
|
sourcemapExcludeSources: true,
|
|
|
|
plugins: [terser()],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
];
|
|
|
|
}
|
|
|
|
|
|
|
|
export default defineConfig([
|
|
|
|
...defineOptions({
|
|
|
|
file: "keycloak",
|
|
|
|
name: "Keycloak",
|
|
|
|
amdId: "keycloak",
|
|
|
|
}),
|
|
|
|
...defineOptions({
|
|
|
|
file: "keycloak-authz",
|
|
|
|
name: "KeycloakAuthorization",
|
|
|
|
amdId: "keycloak-authorization",
|
|
|
|
}),
|
|
|
|
]);
|