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

Disable source maps in production (v2) #3818

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
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
21 changes: 18 additions & 3 deletions packages/gatsby/src/utils/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -316,12 +316,27 @@ module.exports = async (
switch (stage) {
case `develop`:
return `cheap-module-source-map`
// use a normal `source-map` for the html phases since
// use a normal `source-map` for the develop-html phase since
// it gives better line and column numbers
case `develop-html`:
case `build-html`:
case `build-javascript`:
return `source-map`

// Source maps expose too much information about the site so
// we don't generate them by default.
//
// You can easily enable them in your `gatsby-node.js` but make
// sure that your web server restricts access to them (e.g. with
// basic auth):
//
// exports.modifyWebpackConfig = ({ config, stage }) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

The API for modifying webpack config has changed. Instead of directly mutating the webpack config, there's a new action named setWebpackConfig. If you grep the v2 branch, you'll find a number of usages for this + I think there's docs already.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, fixed.

// switch (stage) {
// case `build-html`:
// case 'build-javascript':
// config.merge({
// devtool: 'source-map'
// })
// }
// }
default:
return false
}
Expand Down