window 未在 gatsby 开发环境中定义
window is not defined in gatsby development env
Getting this error when i try to use react-spring-3d-carousel in gatsby
我也检查了平台上可用的其他解决方案,但 none 对我有用。
我已将 gatsby-nodejs 设置为以下解决方案,但它没有用。
exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
if (stage === "build-html") {
actions.setWebpackConfig({
module: {
rules: [{ test: /react-spring-3d-carousel/, use: loaders.null() }],
},
})
}
}
但它仍然给我错误 window 未定义。我试图从两周后解决此错误,但 none 的解决方案对我有用。帮我解决这个问题。任何帮助将不胜感激。
尝试使用:
exports.onCreateWebpackConfig = ({ loaders, getConfig }) => {
const config = getConfig();
config.module.rules = [
{
test: /react-spring-3d-carousel/,
use: loaders.null(),
},
];
};
方法大致相同,但适用于所有场景。您也可以尝试将此添加到您的条件中:
if (stage === "build-html" || stage === "develop-html")
Getting this error when i try to use react-spring-3d-carousel in gatsby
我也检查了平台上可用的其他解决方案,但 none 对我有用。 我已将 gatsby-nodejs 设置为以下解决方案,但它没有用。
exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
if (stage === "build-html") {
actions.setWebpackConfig({
module: {
rules: [{ test: /react-spring-3d-carousel/, use: loaders.null() }],
},
})
}
}
但它仍然给我错误 window 未定义。我试图从两周后解决此错误,但 none 的解决方案对我有用。帮我解决这个问题。任何帮助将不胜感激。
尝试使用:
exports.onCreateWebpackConfig = ({ loaders, getConfig }) => {
const config = getConfig();
config.module.rules = [
{
test: /react-spring-3d-carousel/,
use: loaders.null(),
},
];
};
方法大致相同,但适用于所有场景。您也可以尝试将此添加到您的条件中:
if (stage === "build-html" || stage === "develop-html")