1
0
mirror of https://github.com/kremalicious/portfolio.git synced 2024-12-22 09:13:19 +01:00

IntersectionObserver polyfill

This commit is contained in:
Matthias Kretschmann 2018-06-23 14:36:07 +02:00
parent fdd6428bb8
commit 3ae7c447c2
Signed by: m
GPG Key ID: 606EEEF3C479A91F
2 changed files with 22 additions and 14 deletions

View File

@ -1,3 +1,11 @@
exports.onInitialClientRender = () => {
require('./src/styles/base.scss')
}
exports.onClientEntry = () => {
// IntersectionObserver polyfill for gatsby-image (Safari, IE)
if (typeof window.IntersectionObserver === 'undefined') {
require('intersection-observer')
console.log('👍 IntersectionObserver is polyfilled') // eslint-disable-line no-console
}
}

View File

@ -3,22 +3,22 @@ const path = require('path')
// Intersection Observer polyfill
// requires `npm install intersection-observer`
// https://github.com/gatsbyjs/gatsby/issues/2288#issuecomment-334467821
exports.onCreateWebpackConfig = ({ actions, loaders, stage }) => {
const { setWebpackConfig } = actions
// exports.onCreateWebpackConfig = ({ actions, loaders, stage }) => {
// const { setWebpackConfig } = actions
if (stage === 'build-html') {
const nullRule = {
test: /intersection-observer/,
use: [loaders.null()]
}
// if (stage === 'build-html') {
// const nullRule = {
// test: /intersection-observer/,
// use: [loaders.null()]
// }
setWebpackConfig({
module: {
rules: [nullRule]
}
})
}
}
// setWebpackConfig({
// module: {
// rules: [nullRule]
// }
// })
// }
// }
//
// Create project pages from projects.yml