简体   繁体   English

生产中的源地图。 他们有必要吗?

[英]Source Maps on Production. Are they necessary?

I have a gulp task created with a Node Module which invoke the GCC compiler whom reduce my JS code a little bit. 我有一个用Node Module创建的gulp任务,它调用GCC编译器,从而使我的JS代码稍微减少了一点。 It's node-minify. 它是节点最小化的。

The problem is that it's not "pipe-out" and I can't use pipes to create the sourcemaps created previously with "uglify" gulp module ("gulp-uglify") on other task. 问题在于它不是“管道输出”,并且我无法使用管道来创建先前在其他任务上使用“ uglify” gulp模块(“ gulp-uglify”)创建的源地图。

gulp.task('gcc', function () {
    new compressor.minify({
        type: 'gcc',
        fileIn: mainFileBundled,
        fileOut: mainFileBundled2,
        callback: function (err, min) {
            console.log(err);
            //console.log(min);
        }
    });
});

It would be the last task to do before put the code on production with the intention to minify even more the js files. 这是将代码投入生产之前的最后一项任务,目的是减少甚至更多的js文件。

So my question is. 所以我的问题是。 It would be necessary to put source maps on production with the premise that we want to protect the code as much as posible? 有必要在我们希望尽可能多地保护代码的前提下,将源地图投入生产。

No, you only need source maps if you want to use them to debug the code. 不,只有要使用源映射来调试代码时,才需要源映射。


Side note: Don't worry about the //# sourceMappingURL=... line in the file (if it survives your minification process). 旁注:不必担心文件中的//# sourceMappingURL=...行(如果它在您的缩小过程中仍然存在)。 Browsers will only attempt to download the source map if you open dev tools and go to the code panel, so you won't be getting 404s for the missing maps in normal use. 如果您打开开发工具并转到代码面板,浏览器将仅尝试下载源地图,因此在正常使用中,您将不会获得缺少地图的404。 It's not ideal, and hopefully your process removes them, but if they're there it's mostly harmless. 这并不理想,希望您的过程将其删除,但是如果它们在那里,则几乎无害。 Of course, if someone did open the dev tools and go to the code panel, yes, the browser would try to get the file (and presumably fail, as you haven't put them on production). 当然,如果有人确实打开了开发工具并转到代码面板,是的,浏览器将尝试获取文件(并且可能会失败,因为您尚未将其投入生产)。

The problem is that it's not "pipe-out" and I can't use pipes to create the sourcemaps created previously with "uglify" gulp module ("gulp-uglify") on other task. 问题在于它不是“管道输出”,并且我无法使用管道来创建先前在其他任务上使用“ uglify” gulp模块(“ gulp-uglify”)创建的源地图。

I do not fully understand the problem you describe here, but it seems to be irrelevant to your actual question, so if you would like help with generation of source maps, please open another question about that. 我不完全理解您在此处描述的问题,但这似乎与您的实际问题无关,因此,如果您希望在生成源地图时获得帮助,请提出另一个问题。

As to your actual question: 关于您的实际问题:

So my question is. 所以我的问题是。 It would be necessary to put source maps on production with the premise that we want to protect the code as much as posible? 有必要在我们希望尽可能多地保护代码的前提下,将源地图投入生产。

Firstly: No, there is no necessity for source maps whatsoever. 首先:不,没有任何必要的源地图。 You need not even generate them, unless you want to use them for debugging. 您甚至不需要生成它们,除非您想将它们用于调试。 And if you do, you will hamper yourself by not making them available. 如果这样做,您将无法使用它们,从而妨碍了自己。

Secondly: Protecting what is essentially an open piece of code is kind of moot. 其次:保护本质上是开放代码的部分内容是没有意义的。 Of course, you can obfuscate what your application does, but a capable and motivated adversary will penetrate that in any case, and there is absolutely nothing oyu can do to prevent that. 当然,您可以混淆应用程序的功能,但是在任何情况下,有能力和积极进取的对手都会渗透到该应用程序中,并且oyu绝对没有任何办法可以阻止这种情况。 If you are worried about security flaws in your application, audit it for those and fix what you find! 如果您担心应用程序中的安全漏洞,请对其进行审核并修复发现的问题! That will actually help you. 这实际上会对您有所帮助。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 在生产版本中启用 Nuxt 源映射 - Enable Nuxt source maps in production build 在生产中使用 css/javascript 源映射的性能影响? - Performance impact of using css / javascript source-maps in production? 带有 Sentry 的 Vercel 中的 Next.js - 在生产中忽略源映射 - Next.js in Vercel with Sentry - ignore source maps in production webpack在源代码地图的生产版本中是否应该有`webpack://`url? - Should webpack have `webpack://` urls in production builds with source maps? 获取[ng:areq]参数'profileCtrl'不是一个函数,在生产环境中未定义。 控制器在本地工作正常 - Getting [ng:areq] Argument 'profileCtrl' is not a function, got undefined in production. Controller works just fine locally 我使用的是Gulp,但未能生成最终的开发脚本进行生产。 - I'm using Gulp and failing to produce the final development script for production. 如何在 Gatsby v2 中关闭生产中的源映射? - How do I turn off source maps in production in Gatsby v2? React/Node js 应用程序在开发中工作,但在生产中不工作。 不断收到“POST https://phlatt.herokuapp.com/send 404(未找到)”错误 - React/Node js app works in development but not in production. Keep getting "POST https://phlatt.herokuapp.com/send 404 (Not Found)" Error 在Google地图中根据需要传播标记 - Spreading markers out as necessary in Google Maps 解码(javascript)源地图 - Decoding (javascript) source maps
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM