From d1bddd5b90821059269f00383394f23c95d150d6 Mon Sep 17 00:00:00 2001 From: konnorrogers Date: Fri, 27 Jun 2025 12:25:23 -0400 Subject: [PATCH] fix custom elements manifest evaluation --- packages/webawesome/docs/.eleventy.js | 31 +++++++++++---------- packages/webawesome/docs/_utils/manifest.js | 6 ++-- 2 files changed, 19 insertions(+), 18 deletions(-) diff --git a/packages/webawesome/docs/.eleventy.js b/packages/webawesome/docs/.eleventy.js index 90e035288..cf9dcbb12 100644 --- a/packages/webawesome/docs/.eleventy.js +++ b/packages/webawesome/docs/.eleventy.js @@ -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 // diff --git a/packages/webawesome/docs/_utils/manifest.js b/packages/webawesome/docs/_utils/manifest.js index bc60ab7a0..79e5c6a76 100644 --- a/packages/webawesome/docs/_utils/manifest.js +++ b/packages/webawesome/docs/_utils/manifest.js @@ -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 => {