-
Notifications
You must be signed in to change notification settings - Fork 1
/
next.config.js
41 lines (37 loc) · 1.27 KB
/
next.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
const stylexPlugin = require("@stylexjs/nextjs-plugin");
const babelrc = require("./.babelrc.js");
/** @type {import("next").NextConfig} */
const nextConfig = {
reactStrictMode: true,
// For some reason, transpile react-native isn't required with App Router.
transpilePackages: ["react-native"],
experimental: {
optimizePackageImports: ["effect"],
// Can't use because: https://github.com/kysely-org/kysely/issues/751
// Also, StyleX is Webpack only.
// turbo: {
// resolveAlias: {
// "react-native": "react-native-web",
// },
// },
},
webpack: (config) => {
config.resolve.alias = {
...(config.resolve.alias || {}),
// Transform all direct `react-native` imports to `react-native-web`
"react-native$": "react-native-web",
};
return config;
},
};
// From https://github.com/facebook/stylex/blob/main/apps/nextjs-example/next.config.js
const plugins = babelrc.plugins;
const [_name, options] = plugins.find(
(plugin) => Array.isArray(plugin) && plugin[0] === "@stylexjs/babel-plugin",
);
const rootDir = options.unstable_moduleResolution.rootDir ?? __dirname;
module.exports = stylexPlugin({
rootDir,
// when `true`, Stylex can't override RNfW styles for some reasone.
useCSSLayers: false,
})(nextConfig);