Chrome does not read the source map created by elixir browserify

I am using Laravel elixir to compile js and css files using gulp. I use Chrome for debugging, and it collects source maps created using mix.styles and mix.scripts but not generated by mix.browserify. I do not see what I am doing wrong. I want him to tell me that I have an error on custom-charts.js on line 45 of the source file, but instead he says that it is on line 14785 of the compiled file. Here is my gulpfile:

var elixir = require('laravel-elixir');

elixir(function(mix) {

    mix.less('app.less', 'resources/assets/css')

        .styles([
            'libs/jquery-ui.min.css',
            'libs/jquery-ui.structure.min.css',
            'libs/jquery-ui.theme.min.css',
            'libs/select2.min.css',        
            'app.css'
        ])

        .browserify('custom-charts.js')

        .scripts([
            'libs/jquery.min.js',
            'libs/bootstrap.min.js',
            'libs/select2.min.js',
            'libs/jquery-ui.min.js',
            'libs/vue.js',
            'plugin-options.js',
            'custom-jquery.js',
            'custom-vue.js',
        ]);
});

Here is custom-charts.js:

import Chart from 'chart.js';

var ctx = document.getElementById("graph").getContext("2d");

var myChart = new Chart(ctx, {
    type: 'bar',
    data: {
        labels: ["Red", "Blue", "Yellow", "Green", "Purple", "Orange"],
        datasets: [{
            label: '# of Votes',
            data: [12, 19, 3, 5, 2, 3],
            backgroundColor: [
                'rgba(255, 99, 132, 0.2)',
                'rgba(54, 162, 235, 0.2)',
                'rgba(255, 206, 86, 0.2)',
                'rgba(75, 192, 192, 0.2)',
                'rgba(153, 102, 255, 0.2)',
                'rgba(255, 159, 64, 0.2)'
            ],
            borderColor: [
                'rgba(255,99,132,1)',
                'rgba(54, 162, 235, 1)',
                'rgba(255, 206, 86, 1)',
                'rgba(75, 192, 192, 1)',
                'rgba(153, 102, 255, 1)',
                'rgba(255, 159, 64, 1)'
            ],
            borderWidth: 1
        }]
    },
    options: {
        scales: {
            yAxes: [{
                ticks: {
                    beginAtZero:true
                }
            }]
        }
    }
});

new Vue({
    el: 'body',

    components: { Graph }
});

It creates a file custom-charts.js.map, and compiled scripts talking about this at the end: //# sourceMappingURL=custom-charts.js.map. Chrome just doesn't read it.

+4
1

,

elixir(function(mix) {
   mix.browserify('index.js');
});

, resources/assets/js, .

laravel-elixir-browserify

npm install --save-dev laravel-elixir-browserify

gulpfile.js

var browserify = require('laravel-elixir-browserify');
0

Source: https://habr.com/ru/post/1654605/


All Articles