javascript - Next.js:尽管在 next.config.js 中有一个 exportPathMap,但找不到 exportPathMap
问题描述
错误:
No "exportPathMap" found in "next.config.js". Generating map from "./pages"
但我确实exportPathMap
基于官方文档:
我的next.config.js
包含:
const withCss = require("@zeit/next-css");
const withSass = require("@zeit/next-sass");
const withTM = require("next-transpile-modules");
module.exports = {
exportPathMap: async function(
defaultPathMap,
{ dev, dir, outDir, distDir, buildId }
) {
return {
"/": { page: "/" },
"/menu": { page: "/menu" },
"/about": { page: "/about" }
};
}
};
module.exports = withCss({
cssModules: true
});
module.exports = withSass(
withTM({
transpileModules: ["react-bulma-components"],
sassLoaderOptions: {
includePaths: ["./components"]
}
})
);
我还尝试删除默认映射:
module.exports = {
exportPathMap: async function() {
return {
"/": { page: "/" },
"/menu": { page: "/menu" },
"/about": { page: "/about" }
};
}
};
以及withCss()
根据我的研究将其移动到内部:
module.exports = withCss({
exportPathMap: async function() {
return {
"/": { page: "/" },
"/menu": { page: "/menu" },
"/about": { page: "/about" }
};
}
});
这两个出口似乎正在工作,但我做错了什么withSass()
?withCss()
编辑:
我next.config.js
在根项目目录中,如果您有任何疑问的话。
解决方案
您正在重新分配您的 module.exports 多次,因此exportPathMap
andwithCss
丢失了。在这种情况下,配置应如下所示:
module.exports = withCss(
withSass(
withTM({
transpileModules: ["react-bulma-components"],
sassLoaderOptions: {
includePaths: ["./components"]
},
exportPathMap: async function(
defaultPathMap,
{ dev, dir, outDir, distDir, buildId }
) {
return {
"/": { page: "/" },
"/menu": { page: "/menu" },
"/about": { page: "/about" }
};
}
})
)
);
推荐阅读
- lucene - 如何根据 Lucene 中可能的大量前缀和后缀检查字符串?
- android - Flutter 发布的应用程序在启动画面上崩溃,除非 '''minifyEnabled''' 和 '''shrinkResources''' 设置为 '''false'''
- perl - 如何将哈希中的数据存储在文件中并将其用于另一个哈希
- python-3.x - 码头文件未在端口上运行
- mocha.js - Spectron 测试以奇怪的原因失败
- html - 在 div + 链接中的链接中垂直居中的 Font Awesome 图标有奇怪的可点击区域
- node.js - 向 Docker 容器中的 API 发送 POST 请求时出现 404 错误
- sql - Oracle 在特定字符出现后删除部分字符串
- swiftui - 在没有导航视图的视图之间切换
- python - 列表追加在 Python 中无法按预期工作