-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathwebpack.config.js
44 lines (38 loc) · 1.57 KB
/
webpack.config.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
const createExpoWebpackConfigAsync = require('@expo/webpack-config');
const path = require("path");
const WorkboxWebpackPlugin = require("workbox-webpack-plugin");
module.exports = async function (env, argv) {
// Set by expo-cli during `expo build:web`
const isEnvProduction = env.mode === "production";
// Create the default config
const config = await createExpoWebpackConfigAsync(env, argv);
/*
resolve victory-native as victory for the Web app
https://formidable.com/open-source/victory/docs/faq/#expo-web-apps-that-use-victory-native
*/
config.resolve.alias['victory-native'] = 'victory';
// https://github.com/expo/examples/blob/master/with-workbox/webpack.config.js
if (isEnvProduction) {
config.plugins.push(
// Generate a service worker script that will precache, and keep up to date,
// the HTML & assets that are part of the webpack build.
new WorkboxWebpackPlugin.InjectManifest({
swSrc: path.resolve(__dirname, "src/service-worker.js"),
dontCacheBustURLsMatching: /\.[0-9a-f]{8}\./,
exclude: [
/\.map$/,
/asset-manifest\.json$/,
/LICENSE/,
/\.js\.gz$/,
// Exclude all apple touch and chrome images because they're cached locally after the PWA is added.
/(apple-touch-startup-image|chrome-icon|apple-touch-icon).*\.png$/,
],
// Bump up the default maximum size (2mb) that's precached,
// to make lazy-loading failure scenarios less likely.
// See https://github.com/cra-template/pwa/issues/13#issuecomment-722667270
maximumFileSizeToCacheInBytes: 5 * 1024 * 1024,
})
);
}
return config;
};