Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optimizing the chunk size using devtool #1520

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we don't need source for production, it will unnecessary increase the bundle size...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe I am missing something here ??

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the same but one corner case here is, in case of any bug in production we don't get any stack trace for debugging the issue.

// '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
Loading