[英]How to move styles folder to src folder in nextjs typescript with tailwindcss?
i'm using nextjs with typescript and tailwindcss.我正在使用带有 typescript 和 tailwindcss 的 nextjs。 I want to move
styles
folder to src
folder, i already added baseUrl
with value src
options in my tsconfig.json
file, but I got an error like this :我想将
styles
文件夹移动到src
文件夹,我已经在我的baseUrl
文件中添加了带有值src
选项的tsconfig.json
,但是出现了这样的错误:
./node_modules/next/dist/compiled/css-loader/cjs.js??ruleSet[1].rules[2].oneOf[5].use[1]!./node_modules/next/dist/compiled/postcss-loader/cjs.js??ruleSet[1].rules[2].oneOf[5].use[2]!./node_modules/tailwindcss/tailwind.css
TypeError: Object.fromEntries is not a function
and how i move styles folder to src folder, i want to make my folder structure simpler.以及如何将样式文件夹移动到 src 文件夹,我想让我的文件夹结构更简单。 thank you
谢谢
config files must be stored in main root like next.config.js .配置文件必须存储在主根目录中,如 next.config.js 。 but style files can be stored in src directory.
但是样式文件可以存储在 src 目录中。 read this doc: https://tailwindcss.com/docs/guides/nextjs
阅读此文档: https : //tailwindcss.com/docs/guides/nextjs
I had the same problem after moving my files under src
to clean up my root directory.将我的文件移动到
src
下以清理我的根目录后,我遇到了同样的问题。 I copied the config options for tailwind.config.js
from this example repo from Tailwind Labs and found that it worked for me.我从 Tailwind Labs 的这个示例存储库中复制了
tailwind.config.js
的配置选项,发现它对我有用。
module.exports = {
purge: {
content: ['./src/**/*.{js,jsx,ts,tsx}', './next.config.js'],
},
...
Delete the .next
folder, then run the dev server again (with npm run dev
).删除
.next
文件夹,然后再次运行开发服务器(使用npm run dev
)。
This worked in my case.这在我的情况下有效。 I'm guessing it's some kind of caching issue.
我猜这是某种缓存问题。 Obviously you'll need to change your
tailwind.config.js
where the content should check ./src/**/*.{js,jsx,ts,tsx}
rather than ./pages/**/*.{js,jsx,ts,tsx}
.显然,您需要更改
tailwind.config.js
内容应检查的./src/**/*.{js,jsx,ts,tsx}
而不是./pages/**/*.{js,jsx,ts,tsx}
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.