Support sourcemap output for production builds#7087
Conversation
changelog: Internal, Build Tooling, Support sourcemap output for production builds to improve debugging
webpack.config.js
Outdated
| const mode = isProductionEnv ? 'production' : 'development'; | ||
| const hashSuffix = isProductionEnv ? '-[contenthash:8]' : ''; | ||
| const devServerPort = process.env.WEBPACK_PORT; | ||
| const devtool = process.env.WEBPACK_DEVTOOL || (isProductionEnv ? false : 'eval-source-map'); |
There was a problem hiding this comment.
maybe one day we could load this from our configs in s3 or equivalent, so we could deploy these?
There was a problem hiding this comment.
maybe one day we could load this from our configs in s3 or equivalent, so we could deploy these?
Could you expand what you had in mind with S3? Technically we can enable these now to be deployed in production, I had simply opted for this route out of build performance's sake (and the difference may not be too much).
There was a problem hiding this comment.
oh I just meant like, if we wanted to this to be deployed in staging or int but not prod, that's best configured through our s3 .yml files, but this doesn't read those
There was a problem hiding this comment.
I've no strong opposition to deploying them everywhere (including production) if we think they'd be helpful. 🤷
There was a problem hiding this comment.
🤷 I guess our application is open source anyways, and most of the time browsers don't download the sourcemaps right? Only when opening developer tools?
There was a problem hiding this comment.
Right, any "risk" with the sourcemaps would be exposing the original source files if we wouldn't want to do that. And we already expose them via this repository 😄
There was a problem hiding this comment.
Ok, I enabled sourcemap output by default in production in 4a29474 and the guidance in 688c564 + c0e9561. It required a bit of additional work since the sourcemaps seemed to use a different content hash than the original source file, so I switched from contenthash to chunkhash for Webpack output in ed8e011 (related docs).
So that the sourcemap output files use the same hash as the JavaScript files
* Support sourcemap output for production builds changelog: Internal, Build Tooling, Support sourcemap output for production builds to improve debugging * Set default production devtool to source-map * Upgrade Webpack dependencies * Use chunkhash for Webpack hash suffix So that the sourcemap output files use the same hash as the JavaScript files * Update guidance for production sourcemaps * Fix words good
🛠 Summary of changes
devtooloption via environment variable, specifically to allow for explicit enabling of sourcemap output in a production builds (where otherwise sourcemaps would not be output by default).relies on local sourcemap buildsas of default sourcemap output in 4a29474 uses production sourcemapsNotably, this would have helped with debugging #7070.
Alternatively, we could consider enabling sourcemaps in production builds, but debugging these errors does not yet appear to be a common enough need to impose an additional performance penalty on every production build.Edit: The pull request has been edited to use this approach as of 4a29474.📜 Testing Plan