Closed alqamabinsadiq closed 5 years ago
Everything works fine in development env (using gatsby develop) but when I generate build using gatsby build. I can't see any gsap animations. Is there any other way to use gsap in gatsby?
gatsby develop
gatsby build
gatsby build not loading gsap.
gsap
gatsby-config.js:
gatsby-config.js
module.exports = { pathPrefix: "/react-rendering", plugins: ["gatsby-plugin-react-helmet", "gatsby-plugin-sass"], }
package.json:
package.json
{ "name": "experience-builder", "description": "Experience Builder", "license": "MIT", "scripts": { "develop": "gatsby develop", "build": "gatsby build", "serve": "gatsby serve" }, "dependencies": { "axios": "^0.18.0", "css": "^2.2.4", "fs": "0.0.1-security", "gatsby": "^2.13.42", "gatsby-plugin-react-helmet": "^3.1.3", "gatsby-plugin-sass": "^2.1.23", "global": "^4.4.0", "gsap": "^3.0.1", "lodash": "^4.17.15", "node-sass": "^4.13.0", "react": "^16.8.6", "react-dom": "^16.8.6", "react-helmet": "^5.2.1" }, "version": "1.0.0", "main": "index.js", "author": "Alqama Bin Sadiq <alqamabinsadiq@gmail.com>", "devDependencies": { "path": "^0.12.7", "prop-types": "^15.7.2" } }
gatsby-node.js:
gatsby-node.js
const tree = require('./tree'); exports.createPages = async ({ actions: { createPage } }) => { for (let i = 0; i < tree.pages.length; i++) { const page = { ...tree.pages[i] }; if (!page.uri) { createPage({ path: `/`, component: require.resolve("./src/templates/Page.js"), context: { tree: tree, currentPage: page } }); } else { createPage({ path: `/${page.uri}`, component: require.resolve("./src/templates/Page.js"), context: { tree: tree, currentPage: page } }); } } };
gatsby-browser.js: N/A gatsby-ssr.js: N/A
gatsby-browser.js
gatsby-ssr.js
After doing some research I found out that I have to add these two lines.
import CSSPlugin from 'gsap/CSSPlugin'; const C = CSSPlugin;
Summary
Everything works fine in development env (using
gatsby develop
) but when I generate build usinggatsby build
. I can't see any gsap animations. Is there any other way to use gsap in gatsby?Relevant information
gatsby build
not loadinggsap
.Environment (if relevant)
File contents (if changed)
gatsby-config.js
:package.json
:gatsby-node.js
:gatsby-browser.js
: N/Agatsby-ssr.js
: N/A