Tailwind 断点不适用于 Next.js SSG
Tailwind breakpoints not working with Next.js SSG
我的 pages
目录中有一个 /latest
页面,其中显示了所有最新的帖子。但是我的 Tailwind 类 (grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4 gap-4
) 不想工作。这是我遇到的问题的并排比较:
本地版本
正式版
我的组件看起来像这样 (./pages/latest.tsx
):
const Latest: React.FC<LatestProps> = ({}) => {
const { t } = useTranslation('latest')
const { data, loading } = useFindLatestQuery()
return (
<>
<Navigation />
<DefaultWrapper>
<div className="w-full">
<div className="w-full flex justify-center">
<h1>{t('recent')}</h1>
</div>
{!loading && data?.posts?.length > 0 ? (
<div className="mt-6 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4 gap-4">
{[...data.posts].map((post, index) => (
<SearchedPost key={index} post={post as unknown as Post} />
))}
</div>
) : (
<p>Loading...</p>
)}
</div>
</DefaultWrapper>
</>
)
}
这是该版本的 link to the production CSS generated by Tailwind, and you'll see that there's nothing related to grid
. Here's also a link。
顺风配置:
module.exports = {
// mode: 'jit',
purge: [
'./components/**/*.{js,jsx,ts,tsx}',
'./pages/**/*.{js,jsx,ts,tsx}',
'./icons/**/*.{js,jsx,ts,tsx}',
],
darkMode: 'class', // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [],
}
我的 pages
目录中有一个 /latest
页面,其中显示了所有最新的帖子。但是我的 Tailwind 类 (grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4 gap-4
) 不想工作。这是我遇到的问题的并排比较:
本地版本 | 正式版 |
---|---|
我的组件看起来像这样 (./pages/latest.tsx
):
const Latest: React.FC<LatestProps> = ({}) => {
const { t } = useTranslation('latest')
const { data, loading } = useFindLatestQuery()
return (
<>
<Navigation />
<DefaultWrapper>
<div className="w-full">
<div className="w-full flex justify-center">
<h1>{t('recent')}</h1>
</div>
{!loading && data?.posts?.length > 0 ? (
<div className="mt-6 grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 2xl:grid-cols-4 gap-4">
{[...data.posts].map((post, index) => (
<SearchedPost key={index} post={post as unknown as Post} />
))}
</div>
) : (
<p>Loading...</p>
)}
</div>
</DefaultWrapper>
</>
)
}
这是该版本的 link to the production CSS generated by Tailwind, and you'll see that there's nothing related to grid
. Here's also a link。
顺风配置:
module.exports = {
// mode: 'jit',
purge: [
'./components/**/*.{js,jsx,ts,tsx}',
'./pages/**/*.{js,jsx,ts,tsx}',
'./icons/**/*.{js,jsx,ts,tsx}',
],
darkMode: 'class', // or 'media' or 'class'
theme: {
extend: {},
},
variants: {
extend: {},
},
plugins: [],
}