-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnext.config.ts
More file actions
55 lines (51 loc) · 1.77 KB
/
next.config.ts
File metadata and controls
55 lines (51 loc) · 1.77 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
import type { NextConfig } from "next";
import withPWA from "@ducanh2912/next-pwa";
import webpack from "webpack";
const nextConfig: NextConfig = {
// Disable turbopack to use webpack with polyfills
// turbopack: {},
webpack: (config, { isServer }) => {
if (!isServer) {
// Polyfills for browser environment
config.resolve.fallback = {
...config.resolve.fallback,
buffer: require.resolve('buffer/'),
crypto: require.resolve('crypto-browserify'),
stream: require.resolve('stream-browserify'),
process: require.resolve('process/browser'),
util: require.resolve('util/'),
assert: require.resolve('assert/'),
http: require.resolve('stream-http'),
https: require.resolve('https-browserify'),
os: require.resolve('os-browserify/browser'),
url: require.resolve('url/'),
// Ignore React Native modules (we're browser-only)
'@react-native-async-storage/async-storage': false,
};
// Automatically inject polyfills where needed
config.plugins.push(
new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process/browser',
})
);
// Ignore React Native modules (only used in RN, not browser)
config.plugins.push(
new webpack.NormalModuleReplacementPlugin(
/@react-native-async-storage\/async-storage/,
require.resolve('./scripts/empty-module.js')
)
);
}
return config;
},
};
export default withPWA({
dest: "public",
disable: process.env.NODE_ENV === "development",
register: true,
workboxOptions: {
// Allow larger chunks to be precached (3.5 MB instead of 2 MB default)
maximumFileSizeToCacheInBytes: 3.5 * 1024 * 1024,
},
})(nextConfig);