简体   繁体   English

Chrome 扩展:不加载源映射

[英]Chrome Extension: Not loading source-maps

I am not able to load sourcemap in Chrome Extension for some reason.由于某种原因,我无法在 Chrome 扩展程序中加载源映射。

The folder which is being loaded for Chrome Extension has .map just next to .js file.为 Chrome 扩展加载的文件夹在.js文件旁边有.map With the .js file having the line //# sourceMappingURL=1.9215106f1980d05d2b4c.js.map referencing the .map file path. .js文件的行//# sourceMappingURL=1.9215106f1980d05d2b4c.js.map引用了 .map 文件路径。

However, the Chrome dev-tools is not loading the maps for some reason.但是,由于某种原因,Chrome 开发工具没有加载地图。

I double checked the Chrome settings to make sure that the js source maps is turned on and it is working with a simple Angular project.我仔细检查了 Chrome 设置以确保 js 源映射已打开并且它正在处理一个简单的 Angular 项目。

Also, made sure I have the following in the manifest file:另外,请确保清单文件中包含以下内容:

  "web_accessible_resources":[
    "*.map"
  ],

Attention!注意力! This code is meant for development purposes and not meant for production environments, as it makes use of eval.此代码用于开发目的而不是用于生产环境,因为它使用了 eval。 Mozilla does recomment not to use this. Mozilla 建议不要使用它。

Setting the following property in webpack.config.js worked for me:在 webpack.config.js 中设置以下属性对我有用:

module.exports = {
    //Configuration parameters

    devtool: 'eval-source-map',

    //Other configuration parameters
}

Edit: You'll also have to update manifest.json to allow eval :编辑:您还必须更新 manifest.json 以允许eval

"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"

List of devTool styles: https://webpack.js.org/configuration/devtool/#devtool devTool 样式列表: https ://webpack.js.org/configuration/devtool/#devtool

webpack.config.js explained: https://webpack.js.org/configuration/ webpack.config.js 解释: https ://webpack.js.org/configuration/

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM