Getting this error when i try to use react-spring-3d-carousel in gatsby
I have checked other solution available on the platforms too but none of those worked for me. I have set gatsby-nodejs to the following solution but it didn't work.
exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
if (stage === "build-html") {
actions.setWebpackConfig({
module: {
rules: [{ test: /react-spring-3d-carousel/, use: loaders.null() }],
},
})
}
}
But still its giving me the error window is not defined. I am trying to resolve this error from two weeks but none of the solutions worked for me. Help me to resolve this issue. Any help will be appreciated.
CodePudding user response:
Try using:
exports.onCreateWebpackConfig = ({ loaders, getConfig }) => {
const config = getConfig();
config.module.rules = [
{
test: /react-spring-3d-carousel/,
use: loaders.null(),
},
];
};
The approach is mostly the same but it applies to all scenarios. You can also try adding this to your condition:
if (stage === "build-html" || stage === "develop-html")