fix(styles): stop scanning every component for utility sources
Component discovery is not utility-source discovery: scanning all built-in and plugin component directories made Tailwind/Iconify generate rules for components the app never renders. Packages that need scanning opt in through styles.source. Pre-existing working-tree change, committed as-is rather than authored here. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
@@ -620,10 +620,14 @@ export async function runBuild(appRoot: string): Promise<void> {
|
|||||||
appDir,
|
appDir,
|
||||||
appRoot: root,
|
appRoot: root,
|
||||||
mode: "production",
|
mode: "production",
|
||||||
sources: [
|
// Component discovery is not style discovery. Built-in and plugin
|
||||||
...componentDirs,
|
// components own their CSS; scanning every available component makes
|
||||||
...pluginContributions.styles.flatMap((style) => (style.source ? [style.source] : [])),
|
// Tailwind/Iconify generate rules for packages and components the app
|
||||||
],
|
// never renders. Packages that intentionally use app utilities opt in
|
||||||
|
// through an explicit styles.source contribution.
|
||||||
|
sources: pluginContributions.styles.flatMap((style) =>
|
||||||
|
style.source ? [style.source] : [],
|
||||||
|
),
|
||||||
entries: pluginContributions.styles.flatMap((style) => (style.entry ? [style.entry] : [])),
|
entries: pluginContributions.styles.flatMap((style) => (style.entry ? [style.entry] : [])),
|
||||||
},
|
},
|
||||||
config.styles,
|
config.styles,
|
||||||
|
|||||||
@@ -440,10 +440,9 @@ export async function startServer(opts: ServeOptions): Promise<RunningServer> {
|
|||||||
config: opts.stylesConfig,
|
config: opts.stylesConfig,
|
||||||
appRoot,
|
appRoot,
|
||||||
publicDir: join(appRoot, "public"),
|
publicDir: join(appRoot, "public"),
|
||||||
sources: [
|
// Component discovery is separate from utility-source discovery.
|
||||||
...componentDirs,
|
// Packages that need Tailwind scanning opt in via styles.source.
|
||||||
...pluginContributions.styles.flatMap((style) => (style.source ? [style.source] : [])),
|
sources: pluginContributions.styles.flatMap((style) => (style.source ? [style.source] : [])),
|
||||||
],
|
|
||||||
entries: pluginContributions.styles.flatMap((style) => (style.entry ? [style.entry] : [])),
|
entries: pluginContributions.styles.flatMap((style) => (style.entry ? [style.entry] : [])),
|
||||||
},
|
},
|
||||||
theme,
|
theme,
|
||||||
|
|||||||
Reference in New Issue
Block a user