【问题标题】:Module parse failed: Unexpected token (1:0)模块解析失败:意外令牌 (1:0)
【发布时间】:2022-02-09 18:24:06
【问题描述】:

我正在使用一个名为 ract-chat-widget 的库,它要求我在我的组件中导入 css,就像这样

import 'react-chat-widget/lib/styles.css

但我的构建失败并出现以下错误:

    ERROR in ./node_modules/react-chat-widget/lib/styles.css 1:0
    Module parse failed: Unexpected token (1:0)
    You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders

我也尝试为此添加 css-loader,但错误仍然相同。

     {
        test: /\.(css)$/,
        include: [
          path.resolve(__dirname, `./node_modules/react-chat-widget/lib`)
        ],
        use: [
          {
            loader: `css-loader`,
            options: {
              includePaths: [
                path.resolve(__dirname, `./node_modules/react-chat-widget/lib`)
              ]
            }
          }
        ]
      }

我也尝试过以不同格式提供此配置。我不确定还要检查什么。

【问题讨论】:

    标签: css reactjs webpack css-loader


    【解决方案1】:

    看来我可以在组件的.sccs 文件中导入 CSS,而无需任何额外的 webpack 配置。

    【讨论】:

      猜你喜欢
      • 2020-11-02
      • 2022-11-05
      • 2021-05-11
      • 1970-01-01
      • 2023-03-27
      • 2019-02-15
      • 2020-06-09
      • 1970-01-01
      • 2021-04-26
      相关资源
      最近更新 更多