简体   繁体   English

如何将 libs 中的 react 库中的 css 文件导入 nx 集成 monorepo 中的 next.js 应用程序?

[英]How to import css files from react library inside libs to next.js app in nx integrated monorepo?

Can anyone help out on assets configuration in a nx next.js project.任何人都可以帮助 nx next.js 项目中的资产配置。 I have multiple libs and one next.js project.我有多个库和一个 next.js 项目。 I have got two problems我有两个问题

  1. Some of these libs have imported.css files from node_modules but build failed due to global css conflict其中一些库从 node_modules 导入了 .css 文件,但由于全局 css 冲突而构建失败
  2. How to export css files from libs and consume it in main apps如何从 libs 导出 css 文件并在主要应用程序中使用它

For the first question, it seems that next 13.0.3 causes the imported global.css from node_modules to fail due to global css conflict constraint.对于第一个问题,next 13.0.3 似乎导致从 node_modules 导入的 global.css 由于全局 css 冲突约束而失败。 From what I found, it only happen when the import statement is in the lib.根据我的发现,只有当 import 语句在 lib 中时才会发生。 If imported directly in the nextjs pages, the build is successful.如果直接在nextjs页面导入,则构建成功。

Temporarily Fix:临时修复:

  • Downgrade nextjs to 13.0.2 or将 nextjs 降级到 13.0.2 或
  • Import the global css in the app instead改为在应用程序中导入全局 css

https://github.com/vercel/next.js/releases/tag/v13.0.3 #42615 https://github.com/vercel/next.js/releases/tag/v13.0.3 #42615

It seems that (not sure) this is the culprit that cause NX lib to import global css to fail in nextjs.似乎(不确定)这是导致NX lib导入全局css在nextjs中失败的罪魁祸首。 https://github.com/vercel/next.js/pull/42615 https://github.com/vercel/next.js/pull/42615

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Nx Monorepo - 如何在主 Nest 应用程序中使用 NestJs 库 - Nx Monorepo - How to Use NestJs Library inside the Main Nest App 如何使用在 _app.js (Next.js) 中声明的全局 css 文件中的 css class - How to use css class from global css file declared inside _app.js (Next.js) 如何从 Next.js 中的 css 模块导入样式表? - How to import stylesheet from css modules in Next.js? 如何在 Nx monorepo 内的 Nextjs 应用程序中使用 React-Native 组件 - How to use React-Native components in a Nextjs App inside an Nx monorepo 由于 css 导入,React DatePicker 在 next.js 中不起作用 - React DatePicker no working in next.js because of css import Next.js 全局 CSS 无法从自定义文件以外的文件导入<app></app> - Next.js Global CSS cannot be imported from files other than your Custom <App> 从Create-React-App升级到Next.js - CSS样式表不起作用 - Upgrading From Create-React-App to Next.js - CSS stylesheets are not working 如何在@nrwl/nx monorepo 中导入绝对路径? - How to import absolute paths in a @nrwl/nx monorepo? 将 markdown 文件作为字符串导入 Next.js - Import markdown files as strings in Next.js 如何在 Next.js 中使用带有顺风 css 的 React Suite? - How to Use React Suite with tailwind css in Next.js?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM