在 next.config.js 中导出多个模块:next-images

时间:2021-07-10 07:57:00

标签: reactjs next.js

我需要在 next.config.js 文件中导出 1 个以上的模块。

现在我的文件是这样的:

const nextTranslate = require("next-translate");
module.exports = { ...nextTranslate() };

我也需要把这个:

   const withImages = require('next-images')
   module.exports = withImages()

1 个答案:

答案 0 :(得分:0)

next-compose-plugins 是保持 next.config.js 文件干净的好方法

https://github.com/cyrilwanner/next-compose-plugins

示例:

const withPlugins = require('next-compose-plugins');
const sass = require('@zeit/next-sass');

module.exports = withPlugins([
  [sass],
]);

因为它与您有关:

const nextTranslate = require("next-translate");
const withImages = require("next-images");
const withPlugins = require("next-compose-plugins");

module.exports = withPlugins([
withImages,
nextTranslate
], { other configs here that aren't plugins })

我不确定 nextTranslate 的形状,但这就是它的要点。