是否可以在webpack中禁用某些文件的源映射? [英] Is it possible to disable source maps for certain files in webpack?

查看:252
本文介绍了是否可以在webpack中禁用某些文件的源映射?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想隐藏部分代码,不要在chrome dev工具中显示。是不是可以使用webpack?

I'd like to hide a part of my code from being shown in chrome dev tools. Is it possible with webpack?

推荐答案

我想你可以创建一个身份加载器过滤掉这些特定文件的源图。

I guess you could create an identity loader who filters out sourcemaps for these particular files.

// remove-sourcemap.loader.js
module.exports = function(source, map) {
  this.callback(null, source)
};

然后,在你的webpack配置中:

Then, in your webpack config:

module: {
  loaders: [
    include: [/* list of files (absolute path) for which to remove sourcemaps */],
    loader: 'remove-sourcemap',
  ],
},

您也可以手动应用 SourceMapDevToolPlugin 而不是使用 devtool 配置选项。该插件支持资源匹配,与加载程序相同。

You could also manually apply the SourceMapDevToolPlugin instead of using the devtool configuration option. The plugin supports asset matching in the same way loaders do.

这篇关于是否可以在webpack中禁用某些文件的源映射?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆