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

v2 - Don't generate source maps by default #3817

Closed
tomazy opened this issue Feb 2, 2018 · 13 comments

Comments

@tomazy
Copy link
Contributor

commented Feb 2, 2018

Description

Gatsby by default generates very expressive source maps. They include the full, non-minified source code of the site, including all comments like TODO, etc. They also expose absolute paths to the project directory leaking things like user names and naming conventions.

Source maps in general should not be available to anyone willing to open the dev tools in their browser. Access to them should be restricted and this requires some additional adjustments on the web server level.

I suggest we disable the default source map generation in the next version of the project.

See: #3324 (comment)

@monsieurnebo

This comment has been minimized.

Copy link
Contributor

commented Feb 2, 2018

Agreed! A nice way of managing sourcemaps could be a config parameter, such as:

// gatsby-config.js

module.exports = {

  pathPrefix : "/blog",
  sourceMaps : true,
  // ...

}

It would let users choose when and where use them and would be particulary useful on multi-environments development (develop, staging, etc...).

@jquense

This comment has been minimized.

Copy link
Collaborator

commented Feb 2, 2018

I don't think not generating source maps the right approach. For every production app I've made we've wanted them either to load when devtools were opened or to upload to sentry for clearer error tracking. I think if you don't want them in your uploaded site that's more of publishing concern than a building on?

@KyleAMathews

This comment has been minimized.

Copy link
Contributor

commented Feb 6, 2018

Instead of disabling sourcemaps by default — how about instead we a) investigate using relative paths, removing comments and otherwise making them more tidy by default and b) add a plugin to easily disable producing source maps by modifying the webpack config which also conveniently would speed up builds some.

@monsieurnebo

This comment has been minimized.

Copy link
Contributor

commented Feb 6, 2018

@KyleAMathews I cannot see the advantage of a plugin instead of a basic gatsby-config parameter? 🤔

@KyleAMathews

This comment has been minimized.

Copy link
Contributor

commented Feb 8, 2018

@monsieurnebo mainly because we avoid config options at (almost) all costs :-)

Adding config is a much weightier decision vs. a plugin. Also plugins are much more flexible than config.

@monsieurnebo

This comment has been minimized.

Copy link
Contributor

commented Feb 8, 2018

@KyleAMathews Ok! Would this plugin's purpose be only to disable sourcemaps via webpack configuration? Isn't that a bit overkill?

@KyleAMathews

This comment has been minimized.

Copy link
Contributor

commented Feb 8, 2018

@monsieurnebo that's how a config option would work so it's the same thing

@siakaramalegos

This comment has been minimized.

Copy link
Member

commented Aug 21, 2018

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. If someone has found a way to disable them for production, I would love to know how until either a setting or a plugin is created. 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
    })
  }
};

edit: added an SO question here

@siakaramalegos

This comment has been minimized.

Copy link
Member

commented Aug 21, 2018

So it looks like that might actually work. Either my finder wasn't refreshing the file list or the /public/folder was holding on to old sourcemap files.

@github0013

This comment has been minimized.

Copy link
Contributor

commented Sep 15, 2018

This solved removing source map in v2.
#6289

yarn add gatsby-plugin-no-sourcemaps@next
  plugins: [
    "gatsby-plugin-no-sourcemaps",
  ]
@BillyWM

This comment has been minimized.

Copy link

commented Sep 26, 2018

Neither is working for me. workbox, used by gatsby-plugin-offline is still generating maps for all its files, so apparently all parts in the pipeline don't necessarily respect this setting.

(I did an rm -rf public && gatsby build. This isn't a problem of lingering files. It's definitely regenerating them)

edit: I guess the workbox-build dependency just comes this way.

@gatsbot

This comment has been minimized.

Copy link

commented Jan 16, 2019

Old issues will be closed after 30 days of inactivity. This issue has been quiet for 20 days and is being marked as stale. Reply here or add the label "not stale" to keep this issue open!

@gatsbot

This comment has been minimized.

Copy link

commented Jan 27, 2019

This issue is being closed due to inactivity. Is this a mistake? Please re-open this issue or create a new issue.

@gatsbot gatsbot bot closed this Jan 27, 2019

junhobaik added a commit to junhobaik/junhobaik.github.io that referenced this issue Jun 30, 2019

package 업데이트에 따른 오류 해결
source-map 관련 버전, 의존성 오류로 보임.
webpack-contrib/babel-minify-webpack-plugin#68

gatsby에서 socurcemap을 비활성화하는 플러그인을 이용한 해결
gatsbyjs/gatsby#3817
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
8 participants
You can’t perform that action at this time.