Skip to content

Commit

Permalink
feat(gatsby): allow configuration of default socket type (#27734)
Browse files Browse the repository at this point in the history
  • Loading branch information
wardpeet committed Oct 30, 2020
1 parent 5869cc5 commit f43a6bd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/gatsby/cache-dir/socketIo.js
Expand Up @@ -18,7 +18,7 @@ export default function socketIo() {
try {
// force websocket as transport
socket = io({
transports: [`websocket`],
transports: [process.env.GATSBY_SOCKET_IO_DEFAULT_TRANSPORT],
})

// when websocket fails, we'll try polling
Expand Down
6 changes: 6 additions & 0 deletions packages/gatsby/src/utils/webpack.config.js
Expand Up @@ -86,6 +86,12 @@ module.exports = async (
envObject.BUILD_STAGE = JSON.stringify(stage)
envObject.CYPRESS_SUPPORT = JSON.stringify(process.env.CYPRESS_SUPPORT)

if (stage === `develop`) {
envObject.GATSBY_SOCKET_IO_DEFAULT_TRANSPORT = JSON.stringify(
process.env.GATSBY_SOCKET_IO_DEFAULT_TRANSPORT || `websocket`
)
}

const mergedEnvVars = Object.assign(envObject, gatsbyVarObject)

return Object.keys(mergedEnvVars).reduce(
Expand Down

0 comments on commit f43a6bd

Please sign in to comment.