1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00

Use webpack IgnorePlugin to exclude 'react-is' from production build (#6084)

`react-is` isn't used in production, so we shouldn't bundle it.

Note: most of those plugins are using the `dev` variable, but in case someone runs `NODE_ENV=development next build`, they would need a copy of `react-is` because the conditional use of `react-is` checks `NODE_ENV` — not whether or not HMR is being used (what what the `dev` variable is based on).
This commit is contained in:
Connor Davis 2019-01-18 05:12:29 -06:00 committed by Tim Neutkens
parent c957c9d1a0
commit 8065130343

View file

@ -304,7 +304,15 @@ export default async function getBaseWebpackConfig (dir, {dev = false, isServer
!isServer && new BuildManifestPlugin(), !isServer && new BuildManifestPlugin(),
isServer && new NextJsSsrImportPlugin(), isServer && new NextJsSsrImportPlugin(),
target !== 'serverless' && isServer && new NextJsSSRModuleCachePlugin({outputPath}), target !== 'serverless' && isServer && new NextJsSSRModuleCachePlugin({outputPath}),
target !== 'serverless' && !isServer && !dev && new AssetsSizePlugin(buildId, distDir) target !== 'serverless' && !isServer && !dev && new AssetsSizePlugin(buildId, distDir),
!dev && new webpack.IgnorePlugin({
checkResource: (resource) => {
return /react-is/.test(resource)
},
checkContext: (context) => {
return /next-server[\\/]dist[\\/]/.test(context) || /next[\\/]dist[\\/]/.test(context)
}
})
].filter(Boolean) ].filter(Boolean)
} }