Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should I deploy sourcemaps to production?

Tags:

I'm deploying my website - a static site built in GatsbyJS - and my sourcemaps are by far my largest files. I have 3 sourcemap files that are ~ 3MB. Overall they make up maybe 70% of my build.

  • Should I deploy them to my production server?

  • Are sourcemaps only downloaded by users that open devtools?

like image 336
Paul N Avatar asked Oct 04 '17 16:10

Paul N


People also ask

Should you use Sourcemaps in production?

Most JavaScript and CSS sources are usually minified and source maps serve as a memory map to the compressed files. It's generally a good practice to minify and combine your assets (Javascript & CSS) when deploying to production.

What are Sourcemaps used for?

A source map is a file that maps from the transformed source to the original source, enabling the browser to reconstruct the original source and present the reconstructed original in the debugger.

What are js Sourcemaps?

A Sourcemap is a file that maps from the transformed source to the original source. It is a mapping between the generated/transpiled/minified JavaScript file and one or more original source files. The main purpose of Sourcemaps is to aid debugging.


1 Answers

Considering what a source map is you just need to take into account that:

  • If they are served publicly users can get access to your source code (only if source map files are requested with the proper tools, of course).
  • Need more disk space (in your case ~3 MB)

But, of course, you might need them on production mode in case you need to debug your application (on production mode, since they are not needed for debugging purposes on development mode) (See Source maps files in production - Is it safe? and Why use source maps in production?).

So, this decision is completely up to you according to your needs and requirements, having in mind the previously mentioned points.

like image 119
lealceldeiro Avatar answered Sep 23 '22 17:09

lealceldeiro