Skip to content
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

Add API for hooking into the web and static entries #388

Closed
tribou opened this issue Aug 12, 2016 · 4 comments
Closed

Add API for hooking into the web and static entries #388

tribou opened this issue Aug 12, 2016 · 4 comments
Labels
stale? Issue that may be closed soon due to the original author not responding any more.

Comments

@tribou
Copy link
Contributor

tribou commented Aug 12, 2016

I saw you can respond to route transitions, but is there a way to hook up browser initialization tasks like creating a redux store or starting the offline-plugin runtime?

@benstepp
Copy link
Contributor

benstepp commented Aug 12, 2016

We needed to put redux in our latest project, and as far as I know there isn't a way using gatsby-browser to hook into the entry. What we did was just copy the static-entry and web-entry files and just did what we needed there. We used modifyWebpackConfig to point to the entries. I think a great idea for a starter would be one set up with redux.

export function modifyWebpackConfig(config, stage) {
  if (stage === 'develop') {
    config._config.entry = [
      require.resolve('webpack-hot-middleware/client'),
      require.resolve('babel-polyfill'),
      path.resolve(__dirname, 'web-entry.js'),
    ]
  } else if (stage === 'build-javascript') {
    config._config.entry = {
      main: [require.resolve('babel-polyfill'), path.resolve(__dirname, 'web-entry.js')]
    }
  } else if (stage === 'build-html') {
    config._config.entry = {
      main: [require.resolve('babel-polyfill'), path.resolve(__dirname, 'static-entry.js')]
    }
  }

  return config
}

@KyleAMathews
Copy link
Contributor

This would be an excellent hook to add.

@KyleAMathews KyleAMathews changed the title Possible to integrate Redux using gatsby-browser? Add API for hooking into the web and static entries Sep 2, 2016
@stale
Copy link

stale bot commented Oct 22, 2017

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the stale? Issue that may be closed soon due to the original author not responding any more. label Oct 22, 2017
@stale
Copy link

stale bot commented Nov 7, 2017

This issue has been automatically closed due to inactivity.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stale? Issue that may be closed soon due to the original author not responding any more.
Projects
None yet
Development

No branches or pull requests

3 participants