Skip to content

Instantly share code, notes, and snippets.

@ThaddeusJiang
Created July 31, 2018 11:31
Show Gist options
  • Save ThaddeusJiang/42ad9389e7ab4a0e38ec2b6ed4984d03 to your computer and use it in GitHub Desktop.
Save ThaddeusJiang/42ad9389e7ab4a0e38ec2b6ed4984d03 to your computer and use it in GitHub Desktop.
source map 要不要进入生产环境?

在实际项目中使用 React 时才发现,需要补的知识点那么多。😭

我使用 Parceljs 来打包 React 应用。

parcel build index.html

在 dist 中生成 4 个文件。

index.html
*.js
*.css
*.map

不明白 *.map 文件是做什么的,所以查了一下。 阮老师的文章: http://www.ruanyifeng.com/blog/2013/01/javascript_source_map.html

那么问题来了,source map 要不要进入生产环境?

我的总结

  • 开发环境,代码不压缩 + source map
  • 测试环境,代码压缩 + source map
  • 生产环境,代码压缩 no source map 但是小项目,对性能要求不高的项目,希望在生产环境直接查杀bug的项目。一直保留 source map也不错啊。😄😄😄
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment