19.0.1 • Published 4 months ago

@expo/webpack-config v19.0.1

Weekly downloads
81,024
License
MIT
Repository
github
Last release
4 months ago

⚠️ Expo Webpack is in maintenance mode. We are actively working on a universal bundling solution that works for all platforms.

Documentation

To learn more about how to use this Webpack config, check out the docs here: Customizing the Webpack config

Contributing to the docs

API

Running expo customize:web will generate this default config in your project.

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

module.exports = async function (env, argv) {
  const config = await createExpoWebpackConfigAsync(env, argv);
  // Customize the config before returning it.
  return config;
};

Types

Environment

The main options used to configure how @expo/webpack-config works.

nametypedefaultdescription
projectRootstringrequiredRoot of the Expo project.
httpsbooleanfalseShould the dev server use https protocol.
modeModerequiredThe Webpack mode to bundle the project in.
platformExpoPlatformrequiredThe target platform to bundle for.
pwabooleantrueGenerate the PWA image assets in production mode.
babelExpoBabelOptionsundefinedControl how the default Babel loader is configured.

Environment internal

nametypedefaultdescription
configExpoConfigundefinedThe Expo project config, this should be read using @expo/config.
locationsFilePathsundefinedPaths used to locate where things are.

ExpoPlatform

typedescription
'ios' | 'android' | 'web' | 'electron'The target platform to bundle for. Native platforms are experimental and require a special native runtime.

ExpoBabelOptions

Control how the default Babel loader is configured.

nametypedefaultdescription
dangerouslyAddModulePathsToTranspilestring[]undefinedAdd the names of node_modules that should be included transpilation step.

Guides

PWAs

  • See the docs for expo-pwa to learn more about creating the assets manually.
  • Disable automatic PWA generation with expo build:web --no-pwa.
  • expo build:web will automatically skip any PWA asset that's already linked in the project's local web/index.html.
  • Having sharp CLI installed globally will speed up asset generation, if it's not installed, Jimp will be used instead.

Chrome PWAs

Manifest.json

The manifest.json will be created using the values in the project's app.config.js:

Generating the manifest.json will be skipped if the following exists in the project's web/index.html:

<link rel="manifest" href="..." />

If the icons array is defined in your manifest.json, then Chrome PWA icon generation will be skipped.

Chrome PWA Icons

Icons will be generated using the file defined in your app.config.js under android.icon and it'll fallback to icon.

{
  "icons": [
    {
      "src": "...",
      "sizes": "144x144",
      "type": "image/png"
    },
    {
      "src": "...",
      "sizes": "192x192",
      "type": "image/png"
    },
    {
      "src": "...",
      "sizes": "512x512",
      "type": "image/png"
    }
  ]
}

Favicons

Favicons will be generated using the file defined in your app.config.js under web.favicon and it'll fallback to icon.

Asset generation for Favicons will be individually skipped if any of the following fields exist in your web/index.html:

<link rel="icon" type="image/png" sizes="16x16" href="..." />
<link rel="icon" type="image/png" sizes="32x32" href="..." />
<link rel="shortcut icon" href="..." />

Safari PWAs

Icons will be generated using the file defined in your app.config.js under ios.icon and it'll fallback to icon. The splash screens look at ios.splash and fallback to splash.

Asset generation for Safari PWA icons/splash screens will be individually skipped if any of the following fields exist in your web/index.html:

Icons
<link rel="apple-touch-icon" sizes="180x180" href="..." />
Splash Screens
<link
  rel="apple-touch-startup-image"
  media="screen and (device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)"
  href="..."
/>
<link
  rel="apple-touch-startup-image"
  media="screen and (device-width: 320px) and (device-height: 568px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)"
  href="..."
/>
<link
  rel="apple-touch-startup-image"
  media="screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)"
  href="..."
/>
<link
  rel="apple-touch-startup-image"
  media="screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)"
  href="..."
/>
<link
  rel="apple-touch-startup-image"
  media="screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)"
  href="..."
/>
<link
  rel="apple-touch-startup-image"
  media="screen and (device-width: 414px) and (device-height: 896px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)"
  href="..."
/>
<link
  rel="apple-touch-startup-image"
  media="screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)"
  href="..."
/>
<link
  rel="apple-touch-startup-image"
  media="screen and (device-width: 375px) and (device-height: 812px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)"
  href="..."
/>
<link
  rel="apple-touch-startup-image"
  media="screen and (device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: landscape)"
  href="..."
/>
<link
  rel="apple-touch-startup-image"
  media="screen and (device-width: 414px) and (device-height: 736px) and (-webkit-device-pixel-ratio: 3) and (orientation: portrait)"
  href="..."
/>
<link
  rel="apple-touch-startup-image"
  media="screen and (device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: landscape)"
  href="..."
/>
<link
  rel="apple-touch-startup-image"
  media="screen and (device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2) and (orientation: portrait)"
  href="..."
/>

Include modules

You may find that you want to include universal modules that aren't part of the default modules. You can do this by customizing the Webpack config:

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

module.exports = async function (env, argv) {
  const config = await createExpoWebpackConfigAsync(
    {
      ...env,
      babel: {
        dangerouslyAddModulePathsToTranspile: [
          // Ensure that all packages starting with @evanbacon are transpiled.
          '@evanbacon',
        ],
      },
    },
    argv
  );
  return config;
};

Modify the babel loader

If you want to modify the babel loader further, you can retrieve it using the helper method getExpoBabelLoader like this:

const createExpoWebpackConfigAsync = require('@expo/webpack-config');
const { getExpoBabelLoader } = require('@expo/webpack-config/utils');

module.exports = async function (env, argv) {
  const config = await createExpoWebpackConfigAsync(env, argv);
  const loader = getExpoBabelLoader(config);
  if (loader) {
    // Modify the loader...
  }
  return config;
};

Service workers

Example of using service workers with Expo: npx create-react-native-app -t with-workbox

This webpack config currently does not supply service workers by default, they can be added to the project locally: Adding Service Workers.

Environment Variables

  • EXPO_WEBPACK_DEFINE_ENVIRONMENT_AS_KEYS: Should the define plugin explicitly set environment variables like process.env.FOO instead of creating an object like proces.env: { FOO }. Defaults to false. Next.js uses this to prevent overwriting injected environment variables.
  • IMAGE_INLINE_SIZE_LIMIT: By default, images smaller than 10,000 bytes are encoded as a data URI in base64 and inlined in the CSS or JS build artifact. Set this to control the size limit in bytes. Setting it to 0 will disable the inlining of images. This is only used in production.

License

The Expo source code is made available under the MIT license. Some of the dependencies are licensed differently, with the BSD license, for example.


raodaor-appraodaor-app-poetryraodaor-app1@infinitebrahmanuniverse/nolb-_expo_@spirokit/ecommerce-app-template-typescript@spirokit/expo-router-template@spirokit/expo-template@spirokit/expo-template-typescript@spirokit/travel-app-template-typescriptbookis-mobile-app-componentsbookis-mobile-components@everything-registry/sub-chunk-307conversation-aihva-skjer-hvl-fordeisolated-cross-modulesinfinity-precision-sdklifemate-react-dev-kit@johnnybossboy/template-expowhitedark-expo-webebuy-mobile-devdummybuttonappfaizankhantestnpmpackagefewnwfnewfwefowoexpo-tailwind-componentsexpo-legacy-browser-supportexpo-lib-tryexpo-yarn-workspacesexpo_img_pickergatsby-plugin-react-native-webfirst-app-abhiram-dummy_packagefield-smartexpotemplateappexposcannersdkonboardingfactory-react-native-pdmpablos-design-systempack-sampleogienchatpearl-uikennienpsmobileautomationnative-subpackagemy-test-boiler-platemairiesimplonpollz-componentsmobilekfcreact-native-fluidsreact-native-awesome-library-wowreact-native-code7-boteriareact-native-component-buttonreact-native-component-iconscanningsdkscannersdksalespalrejurerecettesrecytrackreact-native-matirial-ui-v2react-native-super-emojisreact-native-vtrn-graphrne-atsidebargeovistablueskeetbyuhalumnicardgo-mobiletypesense-package-searchcommon-inputcommon-checkboxcloudinary-react-nativetxradicalfaeriesgathering2022concise-conversetwixor-chat-agent-sdktwixoragentappcool-homestinderstickersmashsmcinsurance-rnsitepal-native-v1sitepal-react-nativesitepal-react-native-testsitepal-react-native-test-1sitepal-react-native-test-appcenteridentityclean-arch-react-native-startercode7-boteria-mobile-rntest-storybook-pycofa@mainamiru/expo-app-with-navigation@mregan59/rn-boilerplate@placeinc/react-web-components@expo/xdl@rvis/rvis-rn-template@revodigital/evt-mobile-kit@richardhofmaenner/template-expo-supabasecustom-toggle@rollup-umd/documentationwatchinharrison-xdlwefdsacerchretnerxfewedxfwsdfwefregdocscannerdialafrika-react-native-sdkdonewithit2846xdl
19.0.1

4 months ago

18.1.4

4 months ago

19.0.0

8 months ago

18.1.3

8 months ago

18.1.2

10 months ago

18.1.1

10 months ago

18.1.0

11 months ago

18.0.4

1 year ago

18.0.3

1 year ago

18.0.2

1 year ago

0.17.4

1 year ago

18.0.1

1 year ago

18.0.0

1 year ago

0.17.3

2 years ago

0.17.2

2 years ago

0.17.0

2 years ago

0.17.1

2 years ago

0.16.25

2 years ago

0.16.26

2 years ago

0.16.27

2 years ago

0.16.24

2 years ago

0.16.21

2 years ago

0.16.22

2 years ago

0.16.23

2 years ago

0.16.20

2 years ago

0.16.15

2 years ago

0.16.18

2 years ago

0.16.19

2 years ago

0.16.16

2 years ago

0.16.17

2 years ago

0.16.10

2 years ago

0.16.11

2 years ago

0.16.14

2 years ago

0.16.12

2 years ago

0.16.13

2 years ago

0.16.7

2 years ago

0.16.8

2 years ago

0.16.9

2 years ago

0.16.4

3 years ago

0.16.6

3 years ago

0.16.3

3 years ago

0.16.2

3 years ago

0.16.0

3 years ago

0.15.0

3 years ago

0.14.1

3 years ago

0.14.0

3 years ago

0.13.3

3 years ago

0.13.2

3 years ago

0.13.0

3 years ago

0.13.1

3 years ago

0.12.82

3 years ago

0.12.81

3 years ago

0.12.79

3 years ago

0.12.80

3 years ago

0.12.78

3 years ago

0.12.74

3 years ago

0.12.75

3 years ago

0.12.76

3 years ago

0.12.77

3 years ago

0.12.70

3 years ago

0.12.71

3 years ago

0.12.72

3 years ago

0.12.73

3 years ago

0.12.68

3 years ago

0.12.69

3 years ago

0.12.67

3 years ago

0.12.66

3 years ago

0.12.65

3 years ago

0.12.64

3 years ago

0.12.63

3 years ago

0.12.62

3 years ago

0.12.61

3 years ago

0.12.61-alpha.0

3 years ago

0.12.60

3 years ago

0.12.59

3 years ago

0.12.59-alpha.0

3 years ago

0.12.58

3 years ago

0.12.57

3 years ago

0.12.56

3 years ago

0.12.55

3 years ago

0.12.54

3 years ago

0.12.54-alpha.0

3 years ago

0.12.53

3 years ago

0.12.53-alpha.0

3 years ago

0.12.52

3 years ago

0.12.51

3 years ago

0.12.50

3 years ago

0.12.49

3 years ago

0.12.48

3 years ago

0.12.47

3 years ago

0.12.46

3 years ago

0.12.45

3 years ago

0.12.44

3 years ago

0.12.43

3 years ago

0.12.42

3 years ago

0.12.41

3 years ago

0.12.40

4 years ago

0.12.39

4 years ago

0.12.38

4 years ago

0.12.37

4 years ago

0.12.36

4 years ago

0.12.35

4 years ago

0.12.34

4 years ago

0.12.33

4 years ago

0.12.32

4 years ago

0.12.31

4 years ago

0.12.30

4 years ago

0.12.29

4 years ago

0.12.28

4 years ago

0.12.27

4 years ago

0.12.26

4 years ago

0.12.25

4 years ago

0.12.24

4 years ago

0.12.23

4 years ago

0.12.22

4 years ago

0.12.21

4 years ago

0.12.20

4 years ago

0.12.19

4 years ago

0.12.18

4 years ago

0.12.17

4 years ago

0.12.16

4 years ago

0.12.15

4 years ago

0.12.14

4 years ago

0.12.13

4 years ago

0.12.12

4 years ago

0.12.11

4 years ago

0.12.10

4 years ago

0.12.8

4 years ago

0.12.9

4 years ago

0.12.7

4 years ago

0.12.6

4 years ago

0.12.5

4 years ago

0.12.4

4 years ago

0.12.4-alpha.0

4 years ago

0.12.3

4 years ago

0.12.2

4 years ago

0.12.1

4 years ago

0.12.0

4 years ago

0.11.25

4 years ago

0.11.24

4 years ago

0.11.23

4 years ago

0.11.22

4 years ago

0.11.21

4 years ago

0.11.20

4 years ago

0.11.19

4 years ago

0.11.18

4 years ago

0.11.16

4 years ago

0.11.17

4 years ago

0.11.15

4 years ago

0.11.12

4 years ago

0.11.13

4 years ago

0.11.14

4 years ago

0.11.11

4 years ago

0.11.10

4 years ago

0.11.9

4 years ago

0.11.8

4 years ago

0.11.6

4 years ago

0.11.7

4 years ago

0.11.5

4 years ago

0.11.4

4 years ago

0.11.3

4 years ago

0.11.2

4 years ago

0.11.1

4 years ago

0.11.0

4 years ago

0.10.12

4 years ago

0.10.11

4 years ago

0.10.10

4 years ago

0.10.9

4 years ago

0.10.8

4 years ago

0.10.7

4 years ago

0.10.6

4 years ago

0.10.5

4 years ago

0.10.4

4 years ago

0.10.3

4 years ago

0.10.2

4 years ago

0.10.1

4 years ago

0.10.0

4 years ago

0.9.0

4 years ago

0.8.1

5 years ago

0.8.0

5 years ago

0.7.12

5 years ago

0.7.11

5 years ago

0.7.10

5 years ago

0.7.9

5 years ago

0.7.8

5 years ago

0.7.6

5 years ago

0.7.5

5 years ago

0.7.5-alpha.0

5 years ago

0.7.4

5 years ago

0.7.3

5 years ago

0.7.2

5 years ago

0.7.1

5 years ago

0.7.0

5 years ago

0.6.2

5 years ago

0.6.1

5 years ago

0.6.0

5 years ago

0.5.19

5 years ago

0.5.18

5 years ago

0.5.17

5 years ago

0.5.16

5 years ago

0.5.15

5 years ago

0.5.14

5 years ago

0.5.13

5 years ago

0.5.12

5 years ago

0.5.11

5 years ago

0.5.10

5 years ago

0.5.9

5 years ago

0.5.8

5 years ago

0.5.7

5 years ago

0.5.6

5 years ago

0.5.5

5 years ago

0.5.4

5 years ago

0.5.3

5 years ago

0.5.2

5 years ago

0.5.1

5 years ago

0.5.0

5 years ago

0.4.1-alpha.0

5 years ago

0.4.0

5 years ago

0.3.0

5 years ago

0.2.0

5 years ago

0.1.6

5 years ago

0.1.5

5 years ago

0.1.4

5 years ago

0.1.3

5 years ago

0.1.2

5 years ago

0.1.2-alpha.0

5 years ago

0.1.1

5 years ago

0.1.0-alpha.0

5 years ago