如何通过webpack导入LESS中的Blueprint 2?

时间:2018-01-30 22:33:38

标签: reactjs webpack import less blueprintjs

Blueprint docs说要使用它:

@import "~@blueprintjs/core";

但是,如果我尝试这样做,我会从webpack中收到此错误:

Can't resolve '@blueprintjs/core.less'

Issue 123处理类似问题,很多人建议使用此功能:

@import "~@blueprintjs/core/dist/blueprint.css";

webpack也不喜欢这样:

Module not found: Error: Can't resolve '@blueprintjs/core/dist/blueprint.css'

dist/目录中,我可以看到那里只有一个JS文件:

$ ls node_modules/\@blueprintjs/core/dist/
core.bundle.js

经过一些反复试验,我发现这有效:

@import "~@blueprintjs/core/lib/css/blueprint.css";

但这对我来说似乎不对。此外,没有任何图标通过此方法加载。

这样做的正确方法是什么?

1 个答案:

答案 0 :(得分:1)

其中一个蓝图开发者回复了我的GitHub问题并提供了一些有用的信息。您可以在此处查看完整主题:https://github.com/palantir/blueprint/issues/2057

简而言之,还必须安装@blueprintjs/icons并且必须导入另一个样式表:

@import '~@blueprintjs/core/lib/css/blueprint.css';
@import '~@blueprintjs/icons/lib/css/blueprint-icons.css';