Skip to content

How do I create separate desktop and mobile web builds? #2085

Answered by markstreich
markstreich asked this question in Help
Discussion options

You must be logged in to vote

Posting the solution I came up with, in case anyone finds it useful, or has a better idea. I'm a webpack newb so this took me a lot of trial and error.

This allows me to have a file like Button.mobile.web.tsx that for the mobile build, works like RN platform extensions, and gets priority over Button.web.tsx / Button.tsx. It also allows running the two dev builds concurrently

webpack.config.js

const createExpoWebpackConfigAsync = require('@expo/webpack-config');

const babelOptions = {
  presets: ['babel-preset-expo'],
};

module.exports = async (env, argv) => {
  if (!process.env.WEB_PLATFORM) {
    throw new Error('Missing WEB_PLATFORM env ("desktop" or "mobile")');
  }

  const config = a…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by necolas
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
1 participant