Suddenly my Tailwind started to load very slow when refreshing (hot-reload).
After some research, I found that @tailwind utilities; should not be imported via globals.css so I created a new file called tailwind-utils.css. ( @tailwind base and @tailwind components are also imported from different file called tailwind.css.)
Then, I imported those files in the _app.tsx like below
import '../styles/tailwind.css'
import '../styles/tailwind-utils.css'
import type { AppProps } from 'next/app'
import { GlobalStyles } from 'twin.macro'
function MyApp({ Component, pageProps }: AppProps) {
return (
<>
<GlobalStyles />
<Component {...pageProps} />,
</>
)
}
export default MyApp
And here is my tailwind.config.js file.
module.exports = {
mode: 'jit',
important: true,
content: ['./src/**/*.{js,ts,jsx,tsx}'],
purge: ['./src/**/*.{js,ts,jsx,tsx}'],
darkMode: false,
plugins: [require('daisyui')]
}
Currently, the hot-reload takes more than 40seconds to load so I want to figure a way to go faster loading.
Here is my globals.css
/* @tailwind base;
@tailwind components;
@tailwind utilities; */
html,
body {
padding: 0;
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell,
Fira Sans, Droid Sans, Helvetica Neue, sans-serif;
}
a {
color: inherit;
text-decoration: none;
}
* {
box-sizing: border-box;
}
@import url('https://fonts.googleapis.com/css2?family=IBM Plex Sans:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;1,100;1,200;1,300;1,400;1,500;1,600;1,700&display=swap');
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900&display=swap');
I also noticed that hot-reloads complete in a second when I write CSS from the module, not inline. But when I update CSS using Twin.Macro syntax (Inline CSS) it takes lots time...