How to temporarily disable the browser?

How to temporarily disable browsersync so that it doesn’t enter / change HTML pages? (For testing and debugging.)

+5
source share
2 answers

There seems to be no such configuration option, but one hacky workaround is to use snippetOptions to specify a string that can never be found in HTML:

 snippetOptions: { rule: { match: /qqqqqqqqq/ } } 

If this line cannot be found in HTML, the fragment will never be injected, and browsers will be inert.

+8
source

You can use Yargs to send parameters and enable or disable the watch task.

Remember this command line to install the necessary components:
npm i --save gulp browser-sync yargs runSequence

In the gulpfile.js file:

 browserSync.init({ port: 80, notify: false, cors: true, browser: 'chrome', open: 'local' }); gulp.task('watch', ['browserSync'], function (){ gulp.watch('dev/*.html', browserSync.reload); gulp.watch('dev/**/*.js', browserSync.reload); gulp.watch('dev/**/*.css', browserSync.reload); }); gulp.task('default', function(callback) { var sequence = ['browserSync']; if (args.sync){ sequence.push('watch') } runSequence(sequence,callback); }); 

These if (args.sync) lines use truthfulness / falsehood, looking for sync values ​​and turning on / off the watch task.

BrowserSync with a clock:
gulp --sync true

BrowserSync without hours:
gulp or gulp --sync false

0
source

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


All Articles