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
Enable source maps in webpack chunking + bundling process #3793
Changes from 4 commits
11e4f3d
7a9f16d
7082eb7
086efe1
479ca8f
1caf81d
0d82e34
23fcf6d
e2366e9
87f5c5a
f2a879d
51230f9
b358c9e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,7 +6,6 @@ import CaseSensitivePathPlugin from 'case-sensitive-paths-webpack-plugin' | |
import WriteFilePlugin from 'write-file-webpack-plugin' | ||
import FriendlyErrorsWebpackPlugin from 'friendly-errors-webpack-plugin' | ||
import {getPages} from './webpack/utils' | ||
import CombineAssetsPlugin from './plugins/combine-assets-plugin' | ||
import PagesPlugin from './plugins/pages-plugin' | ||
import NextJsSsrImportPlugin from './plugins/nextjs-ssr-import' | ||
import DynamicChunksPlugin from './plugins/dynamic-chunks-plugin' | ||
|
@@ -248,15 +247,11 @@ export default async function getBaseWebpackConfig (dir, {dev = false, isServer | |
new webpack.DefinePlugin({ | ||
'process.env.NODE_ENV': JSON.stringify(dev ? 'development' : 'production') | ||
}), | ||
!isServer && new CombineAssetsPlugin({ | ||
input: ['manifest.js', 'react.js', 'commons.js', 'main.js'], | ||
output: 'app.js' | ||
}), | ||
!dev && new webpack.optimize.ModuleConcatenationPlugin(), | ||
!isServer && new PagesPlugin(), | ||
!isServer && new DynamicChunksPlugin(), | ||
isServer && new NextJsSsrImportPlugin({ dir, dist: config.distDir }), | ||
!isServer && new webpack.optimize.CommonsChunkPlugin({ | ||
dev && !isServer && new webpack.optimize.CommonsChunkPlugin({ | ||
name: `commons`, | ||
filename: `commons.js`, | ||
minChunks (module, count) { | ||
|
@@ -287,7 +282,7 @@ export default async function getBaseWebpackConfig (dir, {dev = false, isServer | |
return count >= totalPages * 0.5 | ||
} | ||
}), | ||
!isServer && new webpack.optimize.CommonsChunkPlugin({ | ||
dev && !isServer && new webpack.optimize.CommonsChunkPlugin({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This negates the react split bundle optimization with uglify. It might not be needed anymore because of the uglify optimizations we did though. cc @arunoda There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ptomasroos let's remove this as well. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
name: 'react', | ||
filename: 'react.js', | ||
minChunks (module, count) { | ||
|
@@ -306,9 +301,34 @@ export default async function getBaseWebpackConfig (dir, {dev = false, isServer | |
return false | ||
} | ||
}), | ||
!isServer && new webpack.optimize.CommonsChunkPlugin({ | ||
dev && !isServer && new webpack.optimize.CommonsChunkPlugin({ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's keep this. |
||
name: 'manifest', | ||
filename: 'manifest.js' | ||
}), | ||
!dev && !isServer && new webpack.optimize.CommonsChunkPlugin({ | ||
name: 'main.js', | ||
filename: 'app.js', | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We can keep this as For dev you may need to use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done |
||
minChunks (module, count) { | ||
// react | ||
if (module.resource && module.resource.includes(`${sep}react-dom${sep}`) && count >= 0) { | ||
return true | ||
} | ||
|
||
if (module.resource && module.resource.includes(`${sep}react${sep}`) && count >= 0) { | ||
return true | ||
} | ||
// react end | ||
|
||
// commons | ||
// If there are one or two pages, only move modules to common if they are | ||
// used in all of the pages. Otherwise, move modules used in at-least | ||
// 1/2 of the total pages into commons. | ||
if (totalPages <= 2) { | ||
return count >= totalPages | ||
} | ||
return count >= totalPages * 0.5 | ||
// commons end | ||
} | ||
}) | ||
].filter(Boolean) | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove this completely. We are removing the react bundle too.
So, there's no need this in
dev
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done