DEV Community

Discussion on: 🚀 Gatsby + React Native for Web + Expo 🥳

Collapse
 
motin profile image
Fredrik Wollsén • Edited

Thanks for this! This got me up and running with SSR in my Typescript Expo project, awesome! However, there is some conflict in Expo's and Gatsby's webpack definitions config which results in process.env.NODE_ENV being set to the string "development" in gatsby-ssr.js and in plugins when running gatsby production builds. Workaround:

exports.onCreateWebpackConfig = ({ getConfig, actions }) => {
  const existingConfig = getConfig();
  const { plugins } = existingConfig;

  // Remove conflicting expo definitions entry which sets process.env.NODE_ENV to "development" always
  if (process.env.NODE_ENV === "production") {
    const filteredPlugins = plugins.filter(plugin => {
      return !(plugin.definitions && plugin.definitions.__DEV__);
    });
    actions.replaceWebpackConfig({
      ...existingConfig,
      plugins: filteredPlugins
    });
  }
};
Collapse
 
sebastienlorber profile image
Sebastien Lorber

Hi,

I'm maintaining the plugin, can you open an issue about this problem?
I'm not totally able to understand, how is it causing troubles? Does it use react development mode even in production build?