Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I turn off source maps in production in Gatsby v2?

I'm struggling how to disable source maps for production since the default Webpack set up is to leave out the devtool option, but Gatsby v2 is enabling it. I've tried coming up with a way based on the old version and the new docs, but it doesn't work:

// gatsby-node.js
exports.onCreateWebpackConfig = ({ actions, stage }) => {
  if (stage === 'build-javascript') {
    // turn off source-maps
    actions.setWebpackConfig({
      devtool: false
    })
  }
};
like image 652
Sia Avatar asked Aug 21 '18 17:08

Sia


1 Answers

The code in the question is the correct solution. The problem was that Gatsby does not delete the /public/ folder on each build so previously created source maps were still there. So, first delete that folder, then run the build step.

like image 183
Sia Avatar answered Sep 22 '22 00:09

Sia