首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Chrome中不使用Sourcemap的断点

Chrome中不使用Sourcemap的断点
EN

Stack Overflow用户
提问于 2016-06-24 14:38:59
回答 3查看 3.7K关注 0票数 0

这是最烦人的问题。我遇到过this before here,但是我在webpack配置和gulp中有相同的设置,我不能在Chrome中正确设置断点。

我已经删除了我的应用程序文件和地图,重新运行gulp webpack,它再次自动生成它,它仍然不会在应用程序中我想要的地方中断:

Webpack配置

代码语言:javascript
复制
var webpack = require('webpack');
var PROD = JSON.parse(process.env.PROD_DEV || '0');
// https://stackoverflow.com/questions/25956937/how-to-build-minified-and-uncompressed-bundle-with-webpack

module.exports = {
    entry: "./entry.js",
    devtool: "source-map",
    output: {
        devtoolLineToLine: true,
        sourceMapFilename: "tickertags.bundle.js.map",
        pathinfo: true,
        path: __dirname,
        filename: PROD ? "tickertags.bundle.min.js" : "tickertags.bundle.js"
    },
    module: {
        loaders: [
            { test: /\.css$/, loader: "style!css" }
        ]
    },
    plugins: PROD ? [
        new webpack.optimize.UglifyJsPlugin({ minimize: true })
    ] : []
};

杯式任务

代码语言:javascript
复制
gulp.task('webpack',['build:html-templates'],function() {
    return gulp.src('entry.js')
    .pipe(webpack( require('./webpack.config.js') ))
    .pipe(gulp.dest('app/assets/js'));
});

// Development watch /////////////////////////////////////////////////////////// ☕️⏎→
gulp.task('watch', function() {
    gulp.watch('app/**/**/*.html', ['build:html-templates']).on('change', function(file) {
        var filePath = file.path.split(rootPath);
        process.stdout.write(gutil.colors.red(' →→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→   ' +filePath[1]+ '\n'));
    });

    gulp.watch('app/assets/imgs/*.svg').on('change', function(file) {
        var filePath = file.path.split(rootPath);
        process.stdout.write(gutil.colors.red(' →→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→   ' +filePath[1]+ '\n'));
    });

    gulp.watch('sass-smacss/sass/**/*.scss', ['app-css']).on('change', function(file) {
        var filePath = file.path.split(rootPath);
        process.stdout.write(gutil.colors.red(' →→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→   ' +filePath[1]+ '\n'));
    });

    gulp.watch(paths.scripts, ['webpack']).on('change', function(file) {
        var filePath = file.path.split(rootPath);
        process.stdout.write(gutil.colors.red(' →→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→→   ' +filePath[1]+ '\n'));
    });
});

gulp.task('default', ['watch', 'webpack']);
EN

回答 3

Stack Overflow用户

回答已采纳

发布于 2016-07-21 16:11:17

发现了有问题的代码块

代码语言:javascript
复制
var alertVolumeUrl = function(ticker, term_id) {
    var url = api.alertsVolume;
    return _.isEmpty(term_id) ? url + ticker : url;
};

function alertsVolume(ticker, params) { 

    var url = alertVolumeUrl(ticker, params.term_id);
    return $http.get(url, {params: params}).then(function(res){
        return res.data.alerts;
});

我不得不重写第二个函数如下:

代码语言:javascript
复制
var alertVolumeUrl = function(ticker, term_id) {
    var url = '/app/api/alerts/volume/';
    return _.isEmpty(term_id) ? url + ticker : url;
};

var alertsVolume = function(ticker, params) {
    return $http.get(alertVolumeUrl(ticker, params.term_id), { params: params }).then(function(res){
        return res.data.alerts;
    });
};

注意第二个函数是如何使用alertVolumeUrl的。

因为某种原因导致了我们的断点失效。

票数 0
EN

Stack Overflow用户

发布于 2016-06-27 17:56:06

源代码地图在当前版本的Chrome:https://bugs.chromium.org/p/chromium/issues/detail?id=611328#c21上被打破

一旦修复了源映射(修复当前在金丝雀中),那么我确信带有源映射的断点也会被修复。

编辑:最后一个链接是一个过时的错误,上面链接的是当前的。

票数 1
EN

Stack Overflow用户

发布于 2016-06-24 14:51:25

据我所知,唯一的解决方案是不要在精简的代码中使用源代码映射。要么编译您的代码,而不缩小,或使用铬开发工具的内置漂亮打印功能。问题是,小型化通常将多行压缩成逗号表达式。开发工具并不将逗号表达式解释为单独的语句,这就是为什么您只能在代码块的开头放置断点。Sourcemaps只是将精简代码的文本表示形式转换回来,但是引擎在精简代码中按行执行它们。

编辑

查看禁用源代码地图是否有帮助,这是您在Chrome中找到设置的地方:

打开开发人员控制台,按F1,然后找到以下复选框

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38016021

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档