-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
next.config.ts
81 lines (72 loc) · 1.82 KB
/
next.config.ts
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
import type { NextConfig } from "next";
import packageJson from "./package.json" with { type: "json" };
const transpilePackages = [
// react-native packages
"react-native",
...Object.keys(packageJson.dependencies).filter(
(dep) => dep.startsWith("react-native") || dep.startsWith("@react-native")
),
];
const nextConfig: NextConfig = {
transpilePackages,
env: {
ENV: process.env.NODE_ENV,
},
experimental: {
turbo: {
rules: {
"*.js": {
loaders: [
{
loader: "string-replace-loader",
options: {
search: "__DEV__",
replace:
process.env.NODE_ENV !== "production" ? "true" : "false",
},
},
],
},
},
resolveAlias: {
"react-native": "react-native-web",
},
resolveExtensions: [
".web.tsx",
".web.ts",
".web.jsx",
".web.js",
".tsx",
".ts",
".jsx",
".js",
".mjs",
".json",
],
},
},
webpack: (config, { webpack }) => {
// react-native packages requires often global __DEV__ constant
config.plugins.push(
new webpack.DefinePlugin({
__DEV__: process.env.NODE_ENV === "production" || true,
})
);
// react-native-web
config.resolve.alias = {
...(config.resolve.alias || {}),
// Transform all direct `react-native` imports to `react-native-web`
"react-native$": "react-native-web",
};
config.resolve.extensions = [
".web.js",
".web.ts",
".web.tsx",
...config.resolve.extensions,
];
// avoid duplicated react
// config.resolve.alias['react'] = path.resolve(__dirname, '.', 'node_modules', 'react');
return config;
},
};
export default nextConfig;