Next.js Discord

Discord Forum

CSS doesnt work on a page

Unanswered
Arboreal ant posted this in #help-forum
Open in Discord
Arboreal antOP
So i have a root layout where i import globals.css i use tailwind and i have a few nested layouts, on the homepage and all other pages the css loads fine but on app/dashboard/page.js css isnt loaded, this only happens in production tho and not in the dev build, this is not an issue with tailwind something is wrong with nextjs

21 Replies

@Birman Do you use standalone output build? If so then you have to copy /public catalog next to the server
Arboreal antOP
i need to copy the public directory?
@Birman https://nextjs.org/docs/pages/api-reference/next-config-js/output#automatically-copying-traced-files
Arboreal antOP
but how do the rest of the pages work now?
only 1 page doesnt
and that page doesnt work when i locally do npm run build and npm run start
@Arboreal ant but how do the rest of the pages work now?
Birman
not sure, would need to have a look at the code, are you sure you are importing the css in most outer layout?
@Arboreal ant im just importing it in the root layout
Birman
maybe remove the .next and node_modules catalogs, are you using standalone output mode? how does your start script look like? just next start? this shouldn't work with standalone output
@Birman maybe remove the .next and node_modules catalogs, are you using standalone output mode? how does your start script look like? just `next start`? this shouldn't work with standalone output
Arboreal antOP
uhh so this is weird, when i build it and run it it has a random chance of not working, sometimes it works, sometimes it doesnt
@Birman Do you have your repo public?
Arboreal antOP
nope, well i guess il just deal with this 50/50, so i tried rebuilding it a few times and most of the time the css loaded
@Arboreal ant nope, well i guess il just deal with this 50/50, so i tried rebuilding it a few times and most of the time the css loaded
Birman
comment out the standalone output and remove the cache .next catalog
Arboreal antOP
yh so even in dev it sometimes doesnt load
@Arboreal ant yh so even in dev it sometimes doesnt load
Birman
then it might be hard to say what's going on without looking at the code
@Birman then it might be hard to say what's going on without looking at the code
Arboreal antOP
this is the page where this happens
onst DashBoard = async () => {

  // getting user data

  return (
    <>
      <NavBar/>
      <div className="flex justify-center pb-10 font-bold text-4xl">
        <h1 className="">My Servers</h1>
      </div>
      <Suspense fallback={<Skeleton />}>
        <MyServer User={User} />
      </Suspense>
    </>
  );
};

export default DashBoard;
@Birman then it might be hard to say what's going on without looking at the code
Arboreal antOP
this probably has to do with the new verison of next, i havent made any changes to my code the past 2 weeks and yesterday i just updated my next version and this started happening, so il try downgrading
@Arboreal ant still happens on 14.2.3 so nope
Birman
Try to make minimal example repo I can have a look tomorrow, otherwise might as well be guessing