Skip to content

Commit

Permalink
Optimize chunk size by changing devtool
Browse files Browse the repository at this point in the history
Signed-off-by: Gowtham Shanmugasundaram <[email protected]>
  • Loading branch information
GowthamShanmugam authored and openshift-cherrypick-robot committed Aug 14, 2024
1 parent 7f0f41a commit 1bcb8c5
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions webpack.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ const NODE_ENV = (process.env.NODE_ENV ||
'development') as webpack.Configuration['mode'];
const PLUGIN = process.env.PLUGIN;
const OPENSHIFT_CI = process.env.OPENSHIFT_CI;
const isProduction = NODE_ENV === 'production';

if (PLUGIN === undefined) {
process.exit(1);
Expand Down Expand Up @@ -86,7 +87,7 @@ const config: webpack.Configuration & DevServerConfiguration = {
{
loader: 'thread-loader',
options: {
...(NODE_ENV === 'development'
...(!isProduction
? { poolTimeout: Infinity, poolRespawn: false }
: OPENSHIFT_CI
? {
Expand Down Expand Up @@ -153,13 +154,15 @@ const config: webpack.Configuration & DevServerConfiguration = {
cwd: process.cwd(),
}),
],
devtool: 'eval-cheap-module-source-map',
// 'source-map' is recommended choice for production builds, A full SourceMap is emitted as a separate file.
// 'eval-source-map' is recommended for development but 'eval-cheap-module-source-map' is faster and gives better result.
devtool: isProduction ? 'source-map' : 'eval-cheap-module-source-map',
optimization: {
chunkIds: 'named',
},
};

if (NODE_ENV === 'production' || process.env.DEV_NO_TYPE_CHECK !== 'true') {
if (isProduction || process.env.DEV_NO_TYPE_CHECK !== 'true') {
config.plugins?.push(
new ForkTsCheckerWebpackPlugin({
issue: {
Expand Down

0 comments on commit 1bcb8c5

Please sign in to comment.