docs(ember): fix the CSS import path in the install guide - #4660
docs(ember): fix the CSS import path in the install guide#4660JamBalaya56562 wants to merge 1 commit into
Conversation
The guide writes the Tailwind entry to `app/styles/app.css` but then imports `./app/styles.css`, which does not exist. Following the guide verbatim makes `vite build` fail to resolve the import, so the project never builds. Verified against a real project scaffolded with `ember-cli init --blueprint @ember/app-blueprint` (@ember/app-blueprint 7.1.1): with the corrected path the app builds and `btn btn-primary` renders with daisyUI styles. closes saadeghi#4658
|
updating the default ember @embroider/virtual/app.css link tag to <link integrity="" rel="stylesheet" href="/app/styles/app.css">is all that is required, no need to import through an ESM script tag. |
|
sorry for stating something wrong about index.html The proposed modification from @evoactivity works, thanks |
|
Thanks @evoactivity — you're right, and thanks for the correction. I rebuilt the app Two things turned up that I think are worth a decision before I change the patch, so Results
#2–#5 all give Environment and method
Fresh
One measurement note, since it tripped me up: the Why the step can't just be deleted (mechanism)I originally wondered whether the import could simply be dropped (#1 above). It can't — // @embroider/compat/dist/src/compat-app.js:390-401
let options = { outputPaths: { app: `/@embroider/virtual/app.css` }, ... };
let nestedInput = funnel(this.combinedStyles(addonTrees), { destDir: 'app/styles' });
let styles = this.preprocessors.preprocessCss(nestedInput, '/app/styles', '/assets', options);
Your change fixes that in the most direct way, and the built <!-- #2 (this PR): unprocessed + processed, and the unprocessed one causes the 404 -->
<link integrity="" rel="stylesheet" href="/@embroider/virtual/app.css">
<link rel="stylesheet" crossorigin="" href="/assets/main-CTagfFYw.css">
<!-- #3 (yours): Vite rewrites it, one sheet -->
<link rel="stylesheet" crossorigin="" href="/assets/main-CTagfFYw.css">Two caveats I hit with #31. v1 addon styles are dropped. Source// compat-app.js:370-388 combinedStyles()
let trees = addonTrees.map(tree => funnel(tree, { srcDir: '_app_styles_' }));
trees.push(appStyles);2. The tests page isn't covered. Where that leaves it
I'll push whichever the maintainers prefer. |

closes #4658
The bug
The Ember guide writes the Tailwind entry to
app/styles/app.css:…and then imports
./app/styles.css— a path that does not exist (styles/is missing). Following the guide verbatim,vite buildfails outright:So the project never builds. One character short of a directory, but it takes the whole guide down.
About the report
@Polve's diagnosis was that a modern Ember app has no
index.html, and that the CSS should be imported fromapp.tsinstead. I scaffolded a fresh app to check, andindex.htmldoes exist —@ember/app-blueprint@7.1.1generates it at the project root (it's a Vite app, so it needs one):So the
index.htmlstep is fine as a location; only the path inside it is wrong. Fixing the path is enough — hence this one-line change rather than a restructure.(For what it's worth, importing from
app/app.jsas suggested works too — I measured both, see below. I keptindex.htmlbecause it's the smaller change and the existing wording stays accurate.)Verification
Scaffolded a real project and followed the guide step by step, changing only the import line:
npx ember-cli@latest init --blueprint @ember/app-blueprint npm install tailwindcss@latest @tailwindcss/vite@latest daisyui@latest # add tailwindcss() to vite.config.mjs, write app/styles/app.css, add the import to index.html npm run buildThen served
dist/and read the computed style of<button class="btn btn-primary">in Chromium:./app/styles.csscannot be resolveddisplay: inline-flex,background: oklch(0.45 0.24 277.023),height: 40px,font-weight: 600— daisyUI applied ✅I also checked the two alternatives so the numbers are on the record:
index.html+./app/styles/app.css(this PR)app/app.js+./styles/app.css(the reporter's suggestion)Removing the step is not an option: Embroider serves
app/styles/app.cssas a virtual module that never passes through@tailwindcss/vite, so without an import that routes it into Vite's module graph the file ships unprocessed — the built@embroider/virtual/app.cssis literally the two source lines.One thing I noticed but did not change
With any of the working variants the browser logs a 404 for
/@embroider/virtual/tailwindcss. Cause: Embroider also servesapp/styles/app.cssraw at/@embroider/virtual/app.css, so the browser tries to resolve the unprocessed@import "tailwindcss"as a URL. Harmless — the real, processed stylesheet loads from/assets/main-*.css— but it is a console error on every page load.It goes away if the Tailwind entry lives outside
app/styles/:Measured: same 21.43 kB, styles applied, zero console errors and zero failed requests. I left it out of this PR because it restructures the guide and adds a new translatable string across 27 locales — happy to send it as a follow-up if you want it.
Translations
No translation changes: the sentence
"Import the CSS file in your index.html"is unchanged, so its key stays in use.bun run lang:prunereports nothing to prune andbun run lang:validatepasses.