将 CSS 从 node_modules 导入到 Create React App
Importing CSS from node_modules into a Create React App
我发现了很多关于此的问题,但 none 的答案有效..
我正在尝试从这个 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 和其他各种方法将其纳入项目。有什么线索吗?
我会在 src/ 中创建一个 assets/fonts/ 目录并将字体放在那里 :)。试一试!
我发现了很多关于此的问题,但 none 的答案有效..
我正在尝试从这个 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 和其他各种方法将其纳入项目。有什么线索吗?
我会在 src/ 中创建一个 assets/fonts/ 目录并将字体放在那里 :)。试一试!