【问题标题】:Importing CSS from node_modules into a Create React App从 node_modules 导入 CSS 到 Create React App
【发布时间】:2018-12-18 23:41:41
【问题描述】:

我发现了很多关于此的问题,但没有一个答案有效..

我正在尝试将来自此 package 的节点模块中的字体导入 Create React 应用程序

我已经设法用

编译它
@import './../node_modules/roboto-fontface/css/roboto/sass/roboto-fontface.scss';

但是一旦我运行它,我就会得到

Module not found: You attempted to import ../../../fonts/roboto/Roboto-Black.eot
 which falls outside of the project src/ directory. Relative imports outside of
src/ are not supported. You can either move it inside src/, or add a symlink to
it from project's node_modules/.

我已经尝试过使用 ~、node_modules 和其他各种方法将其放入项目中。有什么线索吗?

【问题讨论】:

  • 你能解决这个问题吗?

标签: webpack sass create-react-app node-sass-chokidar


【解决方案1】:

我会在 src/ 中创建一个 assets/fonts/ 目录并将字体放在那里 :)。试试看!

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-11-09
    • 2018-07-06
    • 2021-06-24
    • 2019-01-10
    • 2018-06-07
    • 2018-07-03
    • 2021-04-14
    • 2020-10-30
    相关资源
    最近更新 更多