-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwebpack.config.js
More file actions
92 lines (73 loc) · 3.15 KB
/
Copy pathwebpack.config.js
File metadata and controls
92 lines (73 loc) · 3.15 KB
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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
const createExpoWebpackConfigAsync = require('@expo/webpack-config');
const ReactRefreshWebpackPlugin = require("@pmmmwh/react-refresh-webpack-plugin");
// Expo CLI will await this method so you can optionally return a promise.
module.exports = async function (env, argv) {
// Change API URL and Home Page url before upload on Beta and Live servers
env.mode = "production";
// Set this meta tag in index.html
// <meta http-equiv="Cache-control" content="no-cache"><meta http-equiv="Expires" content="-1">
// Comment development for create all build
env.mode = "development";
env.pwa = true;
env.removeUnusedImportExports = true;
const config = await createExpoWebpackConfigAsync(env, argv);
// Customize the config before returning it.
// If you want to add a new alias to the config.
// config.resolve.alias['moduleA'] = 'moduleB';
config.optimization.usedExports = true; // ADD THIS for "react-native-render-html": "^6.3.4" package issue for production build shows white screen with error- Cannot read properties of undefined (reading 'call')
// Prevent minimizing the bundle when you build.
if (config.mode === 'production') {
config.optimization.minimize = true;
config.devtool = false;
// configuration.optimization has an unknown property 'exports'. These properties are valid:
// object { checkWasmTypes?, chunkIds?, concatenateModules?, flagIncludedChunks?, hashedModuleIds?, mangleWasmImports?,
// mergeDuplicateChunks?, minimize?, minimizer?, moduleIds?, namedChunks?, namedModules?, noEmitOnErrors?, nodeEnv?,
// occurrenceOrder?, portableRecords?, providedExports?, removeAvailableModules?, removeEmptyChunks?, runtimeChunk?,
// sideEffects?, splitChunks?, usedExports? }
// -> Enables/Disables integrated optimizations
config.optimization.flagIncludedChunks = false // Added on 24th Feb 2022 for chunk control to be check
// Set custom name for output files
// config.output.filename = 'static/js/myapp.test.js';
// config.output.chunkFilename= 'static/js/myapp.mychunk.chunk.js',
config.optimization.splitChunks = {
cacheGroups: {
default: false,
},
};
config.optimization.runtimeChunk = false;
}
// Maybe you want to turn off compression in dev mode.
if (config.mode === 'development') {
config.devServer.compress = true;
// config.plugins.push( new ReactRefreshWebpackPlugin() );
}
// Added on 20th July 2023 for SVG files by Mukul Agarwal
config.module.rules.forEach((rule) => {
if (rule.oneOf) {
rule.oneOf.unshift({
test: /\.svg$/,
exclude: /node_modules/,
use: [
{
loader: require.resolve("@svgr/webpack"), // "@svgr/webpack": "5.5.0" is compatible till 8.1.0 available
options: {
inlineStyles: {
onlyMatchedOnce: false,
},
viewBox: false,
removeUnknownsAndDefaults: false,
convertColors: false,
},
},
],
});
}
});
// console.log(config);
return config;
};
// module: {
// rules: [
// { test: /\.ts$/, use: 'raw-loader' }
// ]
// }