如何在Gatsby v2中关闭生产中的源地图? [英] How do I turn off source maps in production in Gatsby v2?

查看:76
本文介绍了如何在Gatsby v2中关闭生产中的源地图?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于默认的Webpack设置是省略devtool选项,但我正在努力如何禁用源地图以进行生产,但是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
    })
  }
};

推荐答案

问题中的代码是正确的解决方案.问题在于Gatsby不会在每个版本上删除/public/文件夹,因此以前创建的源映射仍然存在.因此,首先删除该文件夹,然后运行构建步骤.

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.

这篇关于如何在Gatsby v2中关闭生产中的源地图?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆