【发布时间】:2022-01-01 10:19:04
【问题描述】:
如何在不覆盖整个导出对象的情况下将下一个包导入 next.config.js?
我不断看到通过 next.config.js 配置 next.js 的重复模式与其 (config.js) 文档不一致。它涉及将单个导入分配给 module.exports。
例如,从这里提取:https://nextjs.org/docs/advanced-features/using-mdx
Require the package and configure to support top level .mdx pages. The following adds the options object key allowing you to pass in any plugins:
// next.config.js
const withMDX = require('@next/mdx')({
extension: /\.mdx?$/,
options: {
remarkPlugins: [],
rehypePlugins: [],
},
})
module.exports = withMDX({
pageExtensions: ['js', 'jsx', 'md', 'mdx'],
})
来自https://nextjs.org/docs/api-reference/next.config.js/introduction 的 next.config.js 的一般模式是在对象中分配配置。
const nextConfig = {
/* config options here */
}
module.exports = nextConfig
我的问题是,如果此示例中的 MDX 函数用单个函数覆盖 module.exports,我该如何配置 next.js 以使用 mdx 和其他配置?
【问题讨论】:
-
这是否回答了您的问题:How to combine several exports inside one module (module.exports) inside next.config.js file??您可以链接多个 Next.js 插件并将配置对象传递给最里面的插件调用。
标签: next.js