【问题标题】:How do I solve Error importing a css file with next.js?如何解决使用 next.js 导入 css 文件时出错?
【发布时间】:2020-07-24 20:03:16
【问题描述】:

错误:

./node_modules/quill-emoji/dist/quill-emoji.css
ModuleParseError: Module parse failed: Unexpected character '�' (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
(Source code omitted for this binary file)

_app.js,我有:

import "quill-emoji/dist/quill-emoji.css";

next.config.js:

const withCSS = require('@zeit/next-css');
const withImages = require("next-images");
const withPlugins = require("next-compose-plugins");


if (typeof require !== 'undefined') {
    require.extensions['.less'] = () => {};
    require.extensions['.css'] = file => {};
}

module.exports = withPlugins([
    withImages,
    withCSS
], {
    devIndicators: {
        autoPrerender: false,
    },
    webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => {
...
})

【问题讨论】:

    标签: javascript reactjs babeljs next.js


    【解决方案1】:

    emoji css 似乎包含 data:image 的内容并加载 svg 的内联内容。

    我正在尝试使用多个加载器,但找不到正确的序列,您可能需要 resolve-url-loader 在某些特定序列中。

    最好只使用next/head 链接它并收工。

    【讨论】:

      【解决方案2】:

      我认为表情符号图标是 svg。你可能需要一个 svg 加载器来解决这个问题。

      next-images 添加了对 jpg、jpeg、svg、png、ico、webp 和 gif 图像的支持。

      注意:我没有用羽毛笔测试过这个

      这是一个示例 sn-p。

      const withImages = require("next-images");
      
      module.exports = withImages({
          webpack(config, options) {
              return config;
          }
      });
      

      【讨论】:

      • 同样的错误。我正在使用 next-compose-plugins@zeit/next-cssnext-images
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-10-13
      • 2016-10-12
      • 2020-02-21
      • 2016-06-11
      • 2019-02-14
      • 2022-07-25
      相关资源
      最近更新 更多