I’m trying to install react-web-config package in expo react-native application
At first I’m create webpack config by this instruction:
Got the following config:
const createExpoWebpackConfigAsync = require("@expo/webpack-config");
module.exports = async function (env, argv) {
const config = await createExpoWebpackConfigAsync(
{
...env,
// Passing true will enable the default Workbox + Expo SW configuration.
offline: true,
},
argv
);
// Customize the config before returning it.
return config;
};
Checking by:
expo build:web
┌─────────────────────────────────────────────────────────────────────────┐
│
│ │ There is a new version of expo-cli available (3.28.1).
│ │ You are currently using expo-cli 3.27.12
│ │ Install expo-cli globally using the package manager of your
choice; │ │ for example:npm install -g expo-cli
to get the
latest version │ │
│
└─────────────────────────────────────────────────────────────────────────┘√ Expo Webpack Compiled successfully in 1.82s
web Compiled successfully.
web Offline (PWA) support is not enabled in this build. Learn more
{URL}
That’s ok.
Now returning to instruction:
Got new config:
const createExpoWebpackConfigAsync = require("@expo/webpack-config");
const ReactWebConfig = require('react-web-config/lib/ReactWebConfig').ReactWebConfig;
const path = require('path');
const envFilePath = path.resolve(__dirname, '.env');
module.exports = async function (env, argv) {
const config = await createExpoWebpackConfigAsync(
{
...env,
offline: true, // Passing true will enable the default Workbox + Expo SW configuration.
},
argv
);
config.plugins.push(ReactWebConfig(envFilePath));
config.resolve.alias['react-native-config'] = 'react-web-config';
// Customize the config before returning it.
return config;
};
Checking:
expo build:web
Get an error:
- Expo Webpack █████████████████████████ building (10%) 5/6 modules 1 active node_modules@babel\runtime\helpers\classCallCheck.js
(node:7972) DeprecationWarning: Tapable.plugin is deprecated. Use new
API on.hooks
instead (Usenode --trace-deprecation ...
to show
where the warning was created)C:\Users\kxxo\AppData\Local\Yarn\Data\global\node_modules\neo-async\async.js:16
throw new Error(‘Callback was already called.’);
^ Error: Callback was already called.
at throwError (C:\Users\kxxo\AppData\Local\Yarn\Data\global\node_modules\neo-async\async.js:16:11)
at C:\Users\kxxo\AppData\Local\Yarn\Data\global\node_modules\neo-async\async.js:2818:7
at processTicksAndRejections (internal/process/task_queues.js:75:11)
I think problem is in this two new lines:
config.plugins.push(ReactWebConfig(envFilePath));
config.resolve.alias[‘react-native-config’] = ‘react-web-config’;
If I’m comment first or second line, build will successfully compiled (but of course app in this case will not work properly)