2

这是任务:

var gulp = require('gulp'),
    clean = require('gulp-clean'),
    copy = require('gulp-copy'),
    sass = require('gulp-sass'),
    concat = require('gulp-concat'),
    sourcemaps = require('gulp-sourcemaps'),
    uglify = require('gulp-uglify'),
    babel = require('gulp-babel'),
    jshint = require('gulp-jshint'),
    stylish = require('jshint-stylish'),
    Server = require('karma').Server,
    _ = require('lodash');

gulp.task('js-build', ['copy-iso'], function(){
    return gulp.src(['client/src/application.js', 'client/src/**/*.js'])
        .pipe(sourcemaps.init())
        .pipe(babel({
            presets: ['es2015']
        }))
        .pipe(sourcemaps.write('.', {
            sourceRoot: '/src',
            includeContent: false
        }))
        .pipe(gulp.dest('./client/build'));
});

基本上,这会产生一个有时映射不正确的源映射。我测试的方式是在chrome中加载它,打开开发工具并尝试添加断点。这是一个例子:

资源:

(function () {
        'use strict';

        angular
            .module('core')
            .filter('phoneNumberFormat', phoneNumberFormat);

        function phoneNumberFormat() {
            return phoneNumberFilter;

            function phoneNumberFilter(number) {
                /* 
                @param {Number | String} number - Number that will be formatted as telephone number
                Returns formatted number: (###) ###-####
                    else if number.length < 7: (###) ###

                Does not handle country codes that are not '1' (USA)
                */
                if (!number) { return ''; }

                number = number.toString().replace(/[^0-9]+/g, '');

                var formattedNumber = '';

                // if the first character is '1', strip it out and add it back
                var c = (number[0] == '1') ? '1 ' : '';
                number = number[0] == '1' ? number.slice(1) : number;

                // # (###) ###-#### as c (area) front-end
                var area = number.substring(0, 3);
                area = area.length > 0 ? area.length == 3 ? "(" + area + ") " : "(" + area : '';

                var front = number.substring(3, 6);
                front = front + (front.length == 3 ? '-' : '');

                var end = number.substring(6, 10);

                formattedNumber = c + area + front + end;
                return formattedNumber;
            }
        }
    })();

建成:

'use strict';

(function () {
            'use strict';

            angular.module('core').filter('phoneNumberFormat', phoneNumberFormat);

            function phoneNumberFormat() {
                        return phoneNumberFilter;

                        function phoneNumberFilter(number) {
                                    /* 
                                    @param {Number | String} number - Number that will be formatted as telephone number
                                    Returns formatted number: (###) ###-####
                                        else if number.length < 7: (###) ###
                                      Does not handle country codes that are not '1' (USA)
                                    */
                                    if (!number) {
                                                return '';
                                    }

                                    number = number.toString().replace(/[^0-9]+/g, '');

                                    var formattedNumber = '';

                                    // if the first character is '1', strip it out and add it back
                                    var c = number[0] == '1' ? '1 ' : '';
                                    number = number[0] == '1' ? number.slice(1) : number;

                                    // # (###) ###-#### as c (area) front-end
                                    var area = number.substring(0, 3);
                                    area = area.length > 0 ? area.length == 3 ? "(" + area + ") " : "(" + area : '';

                                    var front = number.substring(3, 6);
                                    front = front + (front.length == 3 ? '-' : '');

                                    var end = number.substring(6, 10);

                                    formattedNumber = c + area + front + end;
                                    return formattedNumber;
                        }
            }
})();
//# sourceMappingURL=phone-number.filter.js.map

您可以看到两者几乎相同。不过,我不能在行上放置断点:

return phoneNumberFilter;  

当我这样做时(将断点放置在源文件或构建文件中),我被重定向到它下面的行(function phoneNumberFilter(number) {)。

这些奇怪的重定向几乎在每个文件中都会出现,我似乎找不到任何押韵或理由。有时他们有时会将一行重定向到作用域函数的末尾...idk。

提前致谢。

4

0 回答 0