将 chrome devtools 与 browsersync 配合使用 &--inspect



我一辈子都无法解决如何使用浏览器同步的新--inspect

gulp.task('browser-sync', ['nodemon'], function () {
browserSync({
proxy: 'localhost:17230',
port: 5000,
notify: true,
debug: true
});
});

我已经尝试了调试,但这也没有任何作用:(

几个月前我遇到了同样的问题。您可以使用nodeArgs来将适当的参数传递给节点二进制文件,或者,exec选项也可以使用。

const nodemon = require('gulp-nodemon');
const browserSync = require('browser-sync');
gulp.task('browser-sync', ['nodemon'], function () {
browserSync({
proxy: 'localhost:17230',
port: 5000,
notify: true,
debug: true
});
});
gulp.task('nodemon', function() {
let started = false;
nodemon({
nodeArgs: ['--inspect=0.0.0.0:17230'], // localhost + port
// You may also use {exec: 'node --inspect'}
ext: 'js',
ignore: ['.idea/*', 'node_modules/*'],
script: 'server.js',
tasks: ['lint'],
verbose: true
delay: 2000
})
.on('start', () => {
// to avoid nodemon being started multiple times
if (!started) {
setTimeout(() => done(), 100);
started = true;
}
});
});

最新更新