Skip to content

Commit

Permalink
Merge pull request #1520 from GowthamShanmugam/optimization-1
Browse files Browse the repository at this point in the history
Optimizing the chunk size using devtool
  • Loading branch information
openshift-merge-bot[bot] committed Aug 14, 2024
2 parents 7125996 + eeb5882 commit 3681bf0
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 3681bf0

Please sign in to comment.