fix custom elements manifest evaluation

This commit is contained in:
konnorrogers
2025-06-27 12:25:23 -04:00
parent 103cbc439e
commit d1bddd5b90
2 changed files with 19 additions and 18 deletions

View File

@@ -19,24 +19,25 @@ import { replaceTextPlugin } from './_utils/replace-text.js';
import { searchPlugin } from './_utils/search.js';
const __dirname = url.fileURLToPath(new URL('.', import.meta.url));
const isDev = process.argv.includes('--develop');
const packageData = JSON.parse(await readFile(path.join(__dirname, '..', 'package.json'), 'utf-8'));
const docsDir = path.join(process.env.BASE_DIR || '.', 'docs');
const passThroughExtensions = ['js', 'css', 'png', 'svg', 'jpg', 'mp4'];
const allComponents = getComponents();
/**
* If you plan to add or remove any of these extensions, make sure to let either Konnor or Cory know as these
* passthrough extensions will also need to be updated in the Web Awesome App.
*/
const passThrough = [...passThroughExtensions.map(ext => path.join(docsDir, '**/*.' + ext))];
/**
* This is the guard we use for now to make sure our final built files don't need a 2nd pass by the server. This keeps
* us able to still deploy the bare HTML files on Vercel until the app is ready.
*/
const serverBuild = process.env.WEBAWESOME_SERVER === 'true';
export default async function (eleventyConfig) {
const packageData = JSON.parse(await readFile(path.join(__dirname, '..', 'package.json'), 'utf-8'));
const docsDir = path.join(process.env.BASE_DIR || '.', 'docs');
const allComponents = getComponents();
/**
* If you plan to add or remove any of these extensions, make sure to let either Konnor or Cory know as these
* passthrough extensions will also need to be updated in the Web Awesome App.
*/
const passThrough = [...passThroughExtensions.map(ext => path.join(docsDir, '**/*.' + ext))];
/**
* This is the guard we use for now to make sure our final built files don't need a 2nd pass by the server. This keeps
* us able to still deploy the bare HTML files on Vercel until the app is ready.
*/
const serverBuild = process.env.WEBAWESOME_SERVER === 'true';
//
// Set all global template data here
//

View File

@@ -1,14 +1,14 @@
import { readFileSync } from 'fs';
import { dirname, resolve } from 'path';
import { dirname, resolve, join } from 'path';
import { fileURLToPath } from 'url';
const __dirname = dirname(fileURLToPath(import.meta.url));
const manifest = JSON.parse(readFileSync(resolve(__dirname, '../../dist/custom-elements.json'), 'utf-8'));
/**
* @returns Fetches components from custom-elements.json and returns them in more sane format.
*/
export function getComponents() {
const distDir = process.env.UNBUNDLED_DIST_DIRECTORY || resolve(__dirname, '../../dist')
const manifest = JSON.parse(readFileSync(join(distDir, 'custom-elements.json'), 'utf-8'));
const components = [];
manifest.modules?.forEach(module => {