简体   繁体   English

在带有子文件夹的chrome dev-tools中找不到Grunt Babel Sourcemaps

[英]Grunt Babel sourcemaps not found in chrome dev-tools with sub folder

I've been experimenting with babel using the grunt-babel plugin. 我一直在使用grunt-babel插件尝试grunt-babel Here's my current configuration. 这是我当前的配置。

    babel: {
        options: {
            sourceMap: true,
            presets: ['es2015']
        },
        dist: {
            files: {
                'dist/assets/js/sql-query-builder.js': 'assets/js/sql-query-builder.js',
            }
        }
    }

And here's my directory structure, where the dist folder contains the generated files which are served on my localhost via grunt connect. 这是我的目录结构,其中dist文件夹包含生成的文件,这些文件通过grunt connect在我的本地主机上提供。

- assets
   - js
     - files.js
- dist
  - assets
   - js
     - files.js

When debugging the code the with a console.log in browser the line numbers are incorrect due to the sourcemaps not being picked up. 在浏览器中使用console.log调试代码时,由于未提取源映射,所以行号不正确。 To resolve this i mapped the network file to the local resource like this. 为了解决这个问题,我将网络文件映射到这样的本地资源。

在此处输入图片说明

My first question is should i map to the /dist generated files or the original files in /assets? 我的第一个问题是我应该映射到/ dist生成的文件还是/ assets中的原始文件?

When choosing /dist and dev tools reloads i get the below errors. 选择/ dist和dev工具重新加载时,出现以下错误。

Source map http://localhost:9001/assets/js/sql-query-builder.js.map points to the files missing from the workspace: [http://localhost:9001/assets/js/sql-query-builder.js]

Does that mean i need to update one of the following babel options variables to accomodate the dist file? 这是否意味着我需要更新以下babel选项变量之一以适应dist文件?

sourceMapTarget
sourceFileName
sourceRoot

I'm new to using sourcemaps and babel so I'm assuming I'm making a rookie mistake somewhere. 我是使用sourcemaps和babel的新手,所以我假设我在某个地方犯了一个菜鸟错误。 I want to kick on and explore ES2015 more but without the source mapping debugging is major headache. 我想继续探索ES2015,但如果没有源映射调试,就会非常头痛。

I have read about webpack, browserify and gulp so longer term i will move the build steps to one of those tools but in the short term i want to resolve the issue with my current setup. 我已经阅读了有关webpack,browserify和gulp的信息,因此从更长远的角度来看,我会将构建步骤移至这些工具之一,但短期而言,我想用当前的设置解决问题。

The issue was that the grunt-connect task was serving the /dist as /. 问题是grunt-connect任务将/ dist用作/。 When i changed the grunt task to serve / as / the original source files were found by the sourcemaps. 当我将grunt任务更改为/ as /时,sourcemaps找到了原始源文件。 I think the workspace mapping i talked about was just confusing the issue. 我认为我谈论的工作区映射只是使这个问题感到困惑。

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

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