Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// No splitting of chunks for a server bundle
serverWebpackConfig.optimization = {
minimize: false
}
serverWebpackConfig.plugins.unshift(
new webpack.optimize.LimitChunkCountPlugin({ maxChunks: 1 })
)
// Custom output for the server-bundle that matches the config in
// config/initializers/react_on_rails.rb
serverWebpackConfig.output = {
filename: 'server-bundle.js',
globalObject: 'this',
// If using the React on Rails Pro node server renderer, uncomment the next line
// libraryTarget: 'commonjs2',
path: config.outputPath,
publicPath: config.publicPath,
// https://webpack.js.org/configuration/output/#outputglobalobject
}
// Don't hash the server bundle b/c would conflict with the client manifest
// And no need for the MiniCssExtractPlugin
serverWebpackConfig.plugins = serverWebpackConfig.plugins.filter(
(plugin) =>
plugin.constructor.name !== 'WebpackAssetsManifest' &&
plugin.constructor.name !== 'MiniCssExtractPlugin' &&
plugin.constructor.name !== 'ForkTsCheckerWebpackPlugin'
)
// Configure loader rules for SSR
// Remove the mini-css-extract-plugin from the style loaders because
// the client build will handle exporting CSS.