Skip to content

Commit

Permalink
Include all stories into optimizeDeps.entries (#437)
Browse files Browse the repository at this point in the history
  • Loading branch information
tajo committed May 27, 2023
1 parent 6d720ab commit 04a4662
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions .changeset/green-avocados-develop.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@ladle/react": minor
---

Include all stories into optimizeDeps.entries so all deps get prebundled and there are no further reloads later.
10 changes: 10 additions & 0 deletions packages/ladle/lib/cli/vite-base.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import path from "path";
import react from "@vitejs/plugin-react";
import fs from "fs";
import { globby } from "globby";
import { fileURLToPath } from "url";
import tsconfigPaths from "vite-tsconfig-paths";
import getAppRoot from "./get-app-root.js";
Expand Down Expand Up @@ -89,6 +90,14 @@ const getBaseViteConfig = async (ladleConfig, configFolder, viteConfig) => {
);
debug("Executed from the ladle monorepo: %s", inladleMonorepo);

const storyEntries = (
await globby(
Array.isArray(ladleConfig.stories)
? ladleConfig.stories
: [ladleConfig.stories],
)
).map((story) => path.join(process.cwd(), story));

/**
* @type {import('vite').InlineConfig}
*/
Expand Down Expand Up @@ -139,6 +148,7 @@ const getBaseViteConfig = async (ladleConfig, configFolder, viteConfig) => {
path.join(process.cwd(), ".ladle/components.jsx"),
path.join(process.cwd(), ".ladle/components.tsx"),
path.join(process.cwd(), ".ladle/components.ts"),
...storyEntries,
],
},
plugins: [
Expand Down

1 comment on commit 04a4662

@vercel
Copy link

@vercel vercel bot commented on 04a4662 May 27, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ladle – ./

ladle-miksu.vercel.app
ladle.vercel.app
ladle-git-main-miksu.vercel.app
ladle.dev

Please sign in to comment.