如何对next.config.js模块加载器进行故障排除

时间:2019-08-14 10:03:09

标签: javascript webpack next.js

我现在将zeit的MDX插件与next.js一起使用,并且在我的项目中也提供了dotenv支持。但是,当我尝试包括对CSS文件的支持时,应用程序崩溃了。

它无法识别css导入,因此不会加载css模块。

我安装了@zeit/next-css软件包,这是我的next.config.js配置:

const rehypePrism = require("@mapbox/rehype-prism");

const withMDX = require("@zeit/next-mdx")({
  extension: /\.mdx?$/,
  options: {
    hastPlugins: [rehypePrism]
  }
});

const { parsed: localEnv } = require("dotenv").config();
const webpack = require("webpack");
const withCSS = require("@zeit/next-css");

module.exports = withMDX(
  withCSS({
    pageExtensions: ["js", "jsx", "mdx"],
    webpack(config, { defaultLoaders }) {
      config.plugins.push(new webpack.EnvironmentPlugin(localEnv));
      config.module.rules.push({
        test: /\.(png|jpg|gif)$/,
        use: {
          loader: "url-loader",
          options: {
            limit: 100000
          }
        }
      });
      return config;
    }
  })
);

我检查了this section有关自定义配置的信息,但是如何调试该配置,或者我是否缺少其他信息?

更新:似乎an issue与nextjs和zeit的next-css插件

0 个答案:

没有答案