0

我刚开始使用 Gatsby 进行开发(或一般做前端),我想使用React Suite在我的网站上添加一个导航栏。但是,在 my 中导入相应的样式表时index.js

import 'rsuite/lib/styles/index.less';

运行时收到以下消息gatsby develop

ERROR #98124  WEBPACK
Generating development JavaScript bundle failed
Can't resolve 'rsuite/lib/styles/index.less' in '/Users/.../src/pages'

If you're trying to use a package make sure that 'rsuite/lib/styles/index.less' is installed. If you're trying to use a local file make sure that the path is correct.

File: src/pages/index.js:14:0

failed Building development bundle - 7.237s
ERROR in ./src/pages/index.js 14:0-38
Module not found: Error: Can't resolve 'rsuite/lib/styles/index.less' in '/Users/.../src/pages'
@ ./.cache/_this_is_virtual_fs_path_/$virtual/async-requires.js 31:11-33:5
@ ./.cache/app.js 17:0-52 28:0-70 30:27-40 28:0-70

webpack compiled with 1 error

我已经尝试了很多东西:安装和重新安装rsuite,安装和重新安装gatsby-plugin-lessless清除缓存,尝试各种配置gatsby-config.js,但我真的没有选择。

同时,react-bootstrap通过同样的方式安装和导入样式表

import "bootstrap/dist/css/bootstrap.min.css";

不会产生错误并应用样式表。

非常感谢您的帮助!

4

2 回答 2

0

你可以试试这个:

import "rsuite/src/styles/themes/default/index.less"

https://github.com/rsuite/rsuite/blob/next/examples/with-gatsby/src/pages/index.js#L4

于 2021-03-26T02:55:57.427 回答
0

我认为你应该使用:

import '~rsuite/lib/styles/index.less';

请注意~,因为它是从docs 中推断出来的

于 2021-03-14T13:21:13.473 回答