7

Sometimes we want to get sourcemaps from production server. But we only want developers get those sourcemaps, so there will be some strategy to avoid any other people get sourcemaps, such as limit IP for sourcemap requests.

When sourcemaps are unavailable, Chrome and Firefox won't show any error message. But Safari will show 403/404 errors for those sourcemaps.

My question is: Is there any way to let Safari not show those messages?

Chen An
  • 71
  • 6

1 Answers1

0

If you're willing to debug your code in Chrome, you could omit the reference to the source-map so that it's not initially requested at all, then request the source-map manually from the Sources pane of dev tools.

Webpack has this option:

hidden-source-map - Same as source-map, but doesn’t add a reference comment to the bundle.

https://webpack.github.io/docs/configuration.html#devtool

The Webpack / Chrome combo is working well for me. See the my question for a thorough description of how to apply a hidden source-map.

It may be possible to achieve hidden source-maps with uglify by specifying a blank source-map-url, but I haven't tried this.

--source-map-url - The path to the source map to be added in //# sourceMappingURL. Defaults to the value passed with --source-map.

https://github.com/mishoo/UglifyJS2

If you need to debug in Safari or Firefox, then watch for answers here: How to apply a hidden / remote sourcemap in Safari?

ptim
  • 12,355
  • 8
  • 70
  • 89
  • The question was "Is there any way to let Safari not show those messages?" – Vadim Aug 28 '17 at 10:54
  • 2
    @VadymK this does actually answer the question as I interpreted it: "how to prevent safari throwing 403/404 errors?" Using a `hidden-source-map` will achieve this: safari won't make the request, hence no 404. It's a compromise, though, cos hidden source maps are a bit of a pain. – ptim Aug 30 '17 at 12:51