-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ScrollMagic window is not defined during gatsby build #13141
Comments
You get that error because Following link to documentation from the error you get, you should use For example: const Path = require('path')
exports.onCreateWebpackConfig = ({
stage,
rules,
loaders,
plugins,
actions,
}) => {
actions.setWebpackConfig({
+ module: {
+ rules: stage === 'build-html'
+ ? [
+ {
+ test: /ScrollMagic/,
+ use: loaders.null(),
+ }
+ ]
+ : []
+ },
resolve: {
alias: {
TweenLite: Path.resolve(
'node_modules',
'gsap/src/uncompressed/TweenLite.js'
),
TweenMax: Path.resolve(
'node_modules',
'gsap/src/uncompressed/TweenMax.js'
),
TimelineLite: Path.resolve(
'node_modules',
'gsap/src/uncompressed/TimelineLite.js'
),
TimelineMax: Path.resolve(
'node_modules',
'gsap/src/uncompressed/TimelineMax.js'
),
ScrollMagic: Path.resolve(
'node_modules',
'scrollmagic/scrollmagic/uncompressed/ScrollMagic.js'
),
'animation.gsap': Path.resolve(
'node_modules',
'scrollmagic/scrollmagic/uncompressed/plugins/animation.gsap.js'
),
'debug.addIndicators': Path.resolve(
'node_modules',
'scrollmagic/scrollmagic/uncompressed/plugins/debug.addIndicators.js'
),
},
},
})
} And potentially add any other modules to |
@pieh Hey that worked great! I also had to add
and it built properly, thanks! |
Hey guys, @yongelee I have the same problem you had before. After I did:
It didn't show the error BUT scrollmagic does not work after gatsby build and gatsby serve. It just lost its functionality in production build. In development mode it works. Could you, please, help me and tell me how you fixed this before? I would appreciate that! Thank you! Here are versions of my packages:
|
Description
I am trying to build my gatsby app using ScrollMagic.
I see this error when I run gatsby build
ScrollMagic has an error with the window being undefined.
Steps to reproduce
Create a gatsby project and add scrollmagic and gsap
Create a gatsby-node.js file to add some custom webpack config like
In your component add
import ScrollMagic from 'ScrollMagic'
require('animation.gsap')
require('debug.addIndicators')
Write some scrollmagic code and try running gatsby build. It should have an error.
Expected result
A regular production gatsby build with scroll magic working as intended.
Actual result
Cannot make a production build for gatsby using scrollmagic
Environment
Run
gatsby info --clipboard
in your project directory and paste the output here.The text was updated successfully, but these errors were encountered: