|
1 | | -module.exports = (nextConfig = {}) => Object.assign({}, nextConfig, { |
2 | | - webpack(config, options) { |
3 | | - if (!options.defaultLoaders) { |
4 | | - throw new Error( |
5 | | - 'This plugin is not compatible with Next.js versions below 5.0.0 https://err.sh/next-plugins/upgrade' |
6 | | - ); |
7 | | - } |
| 1 | +module.exports = (nextConfig = {}) => |
| 2 | + Object.assign({}, nextConfig, { |
| 3 | + webpack(config, options) { |
| 4 | + if (!options.defaultLoaders) { |
| 5 | + throw new Error( |
| 6 | + "This plugin is not compatible with Next.js versions below 5.0.0 https://err.sh/next-plugins/upgrade" |
| 7 | + ); |
| 8 | + } |
8 | 9 |
|
9 | | - if (options.isServer) { |
10 | | - config.externals = ['react', 'react-dom', 'react-ssr-prepass', ...config.externals]; |
11 | | - } |
| 10 | + if (options.isServer) { |
| 11 | + config.externals = [ |
| 12 | + "react", |
| 13 | + "react-dom", |
| 14 | + "react-ssr-prepass", |
| 15 | + ...config.externals, |
| 16 | + ]; |
| 17 | + } |
12 | 18 |
|
13 | | - config.resolve.alias = Object.assign({}, config.resolve.alias, { |
14 | | - react: 'preact/compat', |
15 | | - 'react-dom': 'preact/compat' |
16 | | - }); |
| 19 | + config.resolve.alias = Object.assign({}, config.resolve.alias, { |
| 20 | + react: "preact/compat", |
| 21 | + "react-dom": "preact/compat", |
| 22 | + }); |
17 | 23 |
|
18 | | - if (typeof nextConfig.webpack === 'function') { |
19 | | - config = nextConfig.webpack(config, options); |
20 | | - } |
| 24 | + if (typeof nextConfig.webpack === "function") { |
| 25 | + config = nextConfig.webpack(config, options); |
| 26 | + } |
21 | 27 |
|
22 | | - if ( |
23 | | - config.optimization && |
24 | | - config.optimization.splitChunks && |
25 | | - config.optimization.splitChunks.cacheGroups && |
26 | | - config.optimization.splitChunks.cacheGroups.framework |
27 | | - ) { |
28 | | - config.optimization.splitChunks.cacheGroups.framework.test = new RegExp( |
29 | | - '(' + |
30 | | - config.optimization.splitChunks.cacheGroups.framework.test.source + |
31 | | - ')|((?<!node_modules.*)[\\/]node_modules[\\/](preact)[\\/])', |
32 | | - config.optimization.splitChunks.cacheGroups.framework.test.flags |
33 | | - ); |
34 | | - } |
| 28 | + if ( |
| 29 | + config.optimization && |
| 30 | + config.optimization.splitChunks && |
| 31 | + config.optimization.splitChunks.cacheGroups && |
| 32 | + config.optimization.splitChunks.cacheGroups.framework |
| 33 | + ) { |
| 34 | + config.optimization.splitChunks.cacheGroups.framework.test = new RegExp( |
| 35 | + "(" + |
| 36 | + config.optimization.splitChunks.cacheGroups.framework.test.source + |
| 37 | + ")|((?<!node_modules.*)[\\/]node_modules[\\/](preact)[\\/])", |
| 38 | + config.optimization.splitChunks.cacheGroups.framework.test.flags |
| 39 | + ); |
| 40 | + } |
35 | 41 |
|
36 | | - return config; |
37 | | - } |
38 | | -}); |
| 42 | + return config; |
| 43 | + }, |
| 44 | + }); |
0 commit comments