Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dashboard/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,7 @@
<configuration>
<excludes combine.children="append">
<exclude>**/atlas-lineage/dist/**</exclude>
<exclude>**/.frontend-toolchain/**</exclude>
</excludes>
</configuration>
</plugin>
Expand Down
45 changes: 43 additions & 2 deletions dashboard/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,55 @@
* limitations under the License.
*/

import { defineConfig } from "vite";
import { defineConfig, Plugin } from "vite";
import react from "@vitejs/plugin-react-swc";
import path from "path";
import fs from "fs";

const proxyHost = "http://localhost:21000";

let apacheLicense = "";
let apacheHtmlLicense = "";
try {
const viteConfigContent = fs.readFileSync(path.resolve(__dirname, "vite.config.ts"), "utf-8");
const extracted = viteConfigContent.substring(viteConfigContent.indexOf("/*"), viteConfigContent.indexOf("*/") + 2);
if (extracted.includes("Licensed to the Apache Software Foundation")) {
apacheLicense = extracted + "\n";
apacheHtmlLicense = `\n<!--\n${extracted.replace('/*', '').replace('*/', '').trim()}\n-->\n`;
} else {
console.warn("Warning: Could not safely extract the Apache License from vite.config.ts!");
}
} catch (e) {
console.warn("Warning: Failed to read vite.config.ts for license extraction", e);
}

const addLicensePlugin = (): Plugin => {
return {
name: 'add-license',
apply: 'build' as const, // only run during build
generateBundle(_options: any, bundle: any) {
if (!apacheLicense) return;
for (const [fileName, chunk] of Object.entries(bundle)) {
if (fileName.endsWith('.js') || fileName.endsWith('.css')) {
if (chunk && typeof chunk === 'object') {
if ('type' in chunk && chunk.type === 'chunk' && 'code' in chunk) {
(chunk as any).code = apacheLicense + (chunk as any).code;
} else if ('type' in chunk && chunk.type === 'asset' && 'source' in chunk && typeof (chunk as any).source === 'string') {
(chunk as any).source = apacheLicense + (chunk as any).source;
}
}
}
}
},
transformIndexHtml(html: string) {
if (!apacheHtmlLicense) return html;
return html.replace('<head>', `<head>${apacheHtmlLicense}`);
}
};
};

export default defineConfig({
plugins: [react()],
plugins: [react(), addLicensePlugin()],
base: "",
build: {
chunkSizeWarningLimit: 2000,
Expand Down
Loading