Skip to content

Scaffolded host strips @source "./_scan/", so packaged modules' Tailwind classes are never compiled #290

Description

@antosubash

Summary

HostTemplates.AppCss() removes the @source "./_scan/" line when scaffolding:

// cli/SimpleModule.Cli/Templates/HostTemplates.cs
var lines = EmbeddedResourceReader.ReadTemplateLines("Templates.Host.Styles.app.css");
lines.RemoveAll(line => line.Contains("_scan/", StringComparison.Ordinal));

Styles/_scan/ is where the CollectModuleAssets MSBuild target stages every module's
built .pages.js. It is the only way a packaged (NuGet) module's utility classes
reach the compiled CSS — a packaged module has no .tsx under src/modules/, so the
@source "../../modules/**/Pages/**/*.tsx" glob cannot see it.

With the directive stripped, a scaffolded host stages those bundles on every build and
then scans none of them.

Reproduction

sm new project MyApp && cd MyApp
sm install SimpleModule.Users
npm run build && dotnet build src/MyApp.Host

Any utility class used only by the packaged module's pages is absent from
src/MyApp.Host/wwwroot/css/app.css.

Why it matters

Same silent-failure shape as #288: the page renders, some classes work (whatever another
package happens to use literally), and the rest do nothing. It reads as a broken module
rather than a missing @source root.

Note on the fix

The strip looks deliberate — a fresh scaffold has no Styles/_scan/ directory yet, and
Tailwind errors on an @source path that does not exist. So restoring the directive
likely needs the scaffold to create Styles/_scan/ (e.g. with a .gitkeep) so the first
npm run build succeeds before any dotnet build has staged anything there.

Found while fixing #288 in #289; the Tailwind up-to-date check already tracks these
staged bundles, so only the missing @source root remains.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions