-
I know that we can run the dev server by command: npm run dev But I want to find the reason as to why my dev UI is different from build UI when served locally or on Vercel server. Here is the UI when built and served- So I am wondering as to what might be causing this difference and how dev and build work under the hood. If anyone is interested I have shared more info in a previous discussion - #15012 |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 6 replies
-
It's been a few months since you've posted this concern. Have you resolved this issue since then? |
Beta Was this translation helpful? Give feedback.
-
I am also interested in any differences between |
Beta Was this translation helpful? Give feedback.
-
@Taiterbase @toiluj23, yes I was able to resolve this issue. In my case, it was due to the difference between how I had set up (dev) and next build && next start. Take note of a few things to get it sorted -
Now let's quickly see how you can solve this issue on your part -
// postcss.config.js
const purgecss = [
"@fullhuman/postcss-purgecss",
{
content: [
"./node_modules/@brainhubeu/react-carousel/lib/style.css",
"./node_modules/@brainhubeu/react-carousel/lib/style.css.map",
"./node_modules/react-toastify/dist/*.css",
"./components/**/*.js",
"./pages/**/*.js",
],
defaultExtractor: (content) => {
const broadMatches = content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || [];
const innerMatches = content.match(/[^<>"'`\s.()]*[^<>"'`\s.():]/g) || [];
return broadMatches.concat(innerMatches);
},
},
];
module.exports = {
plugins: [
"postcss-import",
"tailwindcss",
"autoprefixer",
...(process.env.NODE_ENV === "production" ? [purgecss] : []),
],
}; Still I would suggest go the first way and copy your code from old repo to new, use SSR:false to use client-side libraries that hate SSR, and you should be good to go. You can reach out to my Twitter @RajeevSinghn if you need help with this. Let me know if you got this working. |
Beta Was this translation helpful? Give feedback.
@Taiterbase @toiluj23, yes I was able to resolve this issue. In my case, it was due to the difference between how I had set up (dev) and next build && next start. Take note of a few things to get it sorted -
If you have used an external library, chances are it doesn't support server-side rendering. I was using react-carousel from Brainhubeu and it having some issues. Resolve it by importing the library via next/dynamic imports with ssr:false option.
Another issue was that I was using/following an outdated boilerplate code for Tailwind and NextJS. Hence the way postcss.config.js was configured was error-prone. Here is the crux of the problem. at least for me - During the dev, everythin…