Skip to content

Commit

Permalink
feat(catalog): Minify Camel Catalog
Browse files Browse the repository at this point in the history
Currently, we're generating the Camel Catalog at build time, in a pretty
fashion.

The issue with this approach is the file size increase.

This pull request minifies those files at the UI build time, but preserves
them in a pretty fashion in the `dist` folder, so it can be analyzed locally for devs.

Fixes: #131
  • Loading branch information
lordrip committed Oct 18, 2023
1 parent dc31fba commit 5c17105
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 1 addition & 1 deletion packages/camel-catalog/src/json-schema-to-typescript.mts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const addTitleToDefinitions = (schema: JSONSchema) => {
}

const title = key.split('.').slice(-1).join('');
console.log(`Adding title to ${key}: ${title}`);
console.log(`\tAdding title to ${key}: ${title}`);

value.title = title;
});
Expand Down
14 changes: 11 additions & 3 deletions packages/ui/vite.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -50,12 +50,20 @@ function copyKaotoCamelCatalog() {
throw new Error(message.join('\n\n'));
}

/** List all the JSON files in the Camel Catalog folder */
const jsonFiles = fs
.readdirSync(camelCatalogPath)
.filter((file) => file.endsWith('.json'))
.map((file) => path.join(camelCatalogPath, file));

return viteStaticCopy({
targets: [
{
src: camelCatalogPath,
dest: '.',
rename: 'camel-catalog',
src: jsonFiles,
dest: 'camel-catalog',
transform: (content, filename) => {
return JSON.stringify(JSON.parse(content));
},
},
],
});
Expand Down

0 comments on commit 5c17105

Please sign in to comment.