由于某些原因,顺风不能在next.js中正确渲染。
我想知道我的设置是否有问题?
Style文件夹- tailwind.css
@顺风基地;
/* Write your own custom base styles here */
/* Start purging... */
@tailwind components;
/* Stop purging. */
/* Write you own custom component styles here */
.btn-blue {
@apply bg-blue-500 text-white font-bold py-2 px-4 rounded;
}
/* Start purging... */
@tailwind utilities;
/* Stop purging. */
/* Your own custom utilities */……
_app.js
import React from "react";
// import "styles/global.scss";
import 'styles/tailwind.css'
import NavbarCustom from "components/Layout/NavbarCustom";
import Footer from "components/Layout/Footer";
import "util/analytics.js";
import { ProvideAuth } from "util/auth.js";
function MyApp({ Component, pageProps }) {
return (
<ProvideAuth>
<>
<NavbarCustom
bg="white"
variant="light"
expand="md"
logo="icons/Logo_512px.png"
/>
<Component {...pageProps} />我做错了什么?如此困惑,通常这种设置是很好的。
这是btw - https://mmap-1xr646x4a.vercel.app/网站。
使用下面的信息,做了一些改变,但仍然奇怪地出现了同样的问题。
https://mmap-hewlbern.moodmap.vercel.app/就是一个例子。
tailwind.config.js
module.exports = {
future: {
removeDeprecatedGapUtilities: true,
},
purge: ['./components/**/*.{js,ts,jsx,tsx}', './pages/**/*.{js,ts,jsx,tsx}'],
theme: {
extend: {
colors: {
'accent-1': '#333',
},
},
},
variants: {},
plugins: [],
}postcss.config.js
module.exports = {
plugins: [
'tailwindcss',
'postcss-flexbugs-fixes',
[
'postcss-preset-env',
{
autoprefixer: {
flexbox: 'no-2009',
},
stage: 3,
features: {
'custom-properties': false,
},
},
],
],
}
{
"name": "MoodMap",
"version": "0.1.0",
"private": true,
"keywords": [
"MoodMap"
],
"dependencies": {
"@analytics/google-analytics": "0.2.2",
"@stripe/stripe-js": "^1.5.0",
"analytics": "0.3.1",
"fake-auth": "0.1.7",
"mailchimp-api-v3": "1.13.1",
"next": "9.5.3",
"query-string": "6.9.0",
"raw-body": "^2.4.1",
"rc-year-calendar": "^1.0.2",
"react": "16.12.0",
"react-dom": "16.12.0",
"react-hook-form": "4.10.1",
"react-query": "2.12.1",
"react-transition-group": "^4.4.1",
"stripe": "^8.52.0"
},
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"stripe-webhook": "stripe listen --forward-to localhost:3000/api/stripe-webhook"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"devDependencies": {
"postcss-flexbugs-fixes": "^4.2.1",
"postcss-preset-env": "^6.7.0",
"stylelint": "^13.7.1",
"stylelint-config-standard": "^20.0.0",
"tailwindcss": "^1.8.9"
}
}谢谢!
发布于 2020-09-24 20:57:41
我觉得你的设置太大了。现在你可以用简单得多的东西来实现这一点。
首先,我认为CSS不再需要加载到nextjs中,并且模块是原生支持的。(所以你可以删除这个withCSS的东西)
其次,如果你使用的是较新的版本,顺风不再需要如此复杂的设置。
因此,您将需要安装postcss-preset-env,但它现在确实消除了对大型配置的需求。
查看此示例https://github.com/vercel/next.js/tree/canary/examples/with-tailwindcss
发布于 2021-05-17 18:13:10
我的项目也有同样的问题,但我尝试这样更改globals.css:
在此之前
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100;200;300;400;500;600;700;800;900');
@tailwind base;
@tailwind components;
@tailwind utilities;之后
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import './base.css';
@import 'tailwindcss/utilities';发布于 2021-10-11 01:05:19
我在一些文件中也有同样的问题。
在删除所有内联顺风类并使用@apply将它们放入CSS文件后,它工作得很好。
https://stackoverflow.com/questions/64032166
复制相似问题