【问题标题】:React Css loader issue when I execute npm start当我执行 npm start 时反应 Css 加载程序问题
【发布时间】:2018-10-01 22:14:37
【问题描述】:

执行 npm start 命令时遇到问题。我使用的是 ubuntu 和 node 4.2.2 版本。

./~/css-loader!./~/autoprefixer-loader?browsers=last 3 中的错误 版本!./~/sass-loader?outputStyle=expanded&includePaths[]=path/node_modules!./src/styles/index.scss 找不到模块:错误:无法解析“文件”或“目录” ../../assets/fonts/Roboto/roboto-light.eot 在路径/src/styles

我的项目文件结构是

webclient/
   assets/
      fonts/
        Material Icons/
        Roboto/
        RobotoDraft/

【问题讨论】:

  • 你有../../assets/fonts/Roboto/roboto-light.eot文件吗?
  • 是的,我有 ../../assets/fonts/Roboto/roboto-light.eot 文件
  • 你能用你的文件结构更新问题吗?

标签: node.js reactjs ubuntu npm-install


【解决方案1】:

安装文件加载器然后测试

  test: /.(ttf|otf|eot|svg|woff(2)?)(\?[a-z0-9]+)?$/,

  use: [
          {
            loader: 'file-loader',
            options: {
              outputPath: 'fonts/',
              name: '[name][hash].[ext]',
          },
        },
      ],

使用文件加载器,你可以将字体保存在构建目录中

你也可以使用 url-loader,这样你就可以在你的构建 js 文件中内联字体。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-04-14
    • 2017-06-15
    • 2021-02-12
    • 1970-01-01
    • 2019-10-02
    • 1970-01-01
    • 2020-03-15
    相关资源
    最近更新 更多