UNPKG

1.64 kBJavaScriptView Raw
1"use strict";
2var __importDefault = (this && this.__importDefault) || function (mod) {
3 return (mod && mod.__esModule) ? mod : { "default": mod };
4};
5Object.defineProperty(exports, "__esModule", { value: true });
6const paths_1 = require("@expo/config/paths");
7const addons_1 = require("./addons");
8const env_1 = require("./env");
9const webpack_config_1 = __importDefault(require("./webpack.config"));
10/**
11 * Create the official Webpack config for loading Expo web apps.
12 *
13 * @param env Environment props used to configure features.
14 * @param argv
15 * @category default
16 */
17async function createWebpackConfigAsync(env = {}, argv = {}) {
18 if (!env.projectRoot) {
19 env.projectRoot = paths_1.getPossibleProjectRoot();
20 }
21 if (!env.platform) {
22 // @ts-ignore
23 env.platform = process.env.EXPO_WEBPACK_PLATFORM;
24 }
25 const environment = env_1.validateEnvironment(env);
26 const config = await webpack_config_1.default(environment, argv);
27 // @ts-ignore: deprecated
28 if (environment.info) {
29 console.warn('environment.info is deprecated');
30 }
31 if (environment.offline === false) {
32 return config;
33 }
34 const { workbox = {} } = argv;
35 const publicUrl = workbox.publicUrl || env_1.getPublicPaths(environment).publicUrl;
36 // No SW for native
37 if (['ios', 'android'].includes(env.platform || '')) {
38 return config;
39 }
40 return addons_1.withWorkbox(config, Object.assign(Object.assign({ projectRoot: environment.projectRoot }, workbox), { publicUrl, platform: env.platform }));
41}
42exports.default = createWebpackConfigAsync;
43//# sourceMappingURL=index.js.map
\No newline at end of file