* Initialize and start BrowserSync * see https://browsersync.io/docs/api#api-watch
()
| 73 | * see https://browsersync.io/docs/api#api-watch |
| 74 | */ |
| 75 | async function startBrowserSync() { |
| 76 | bsync = browserSync.create(); |
| 77 | |
| 78 | bsync.init({ |
| 79 | server: './', |
| 80 | port: 8080, |
| 81 | watchTask: true, |
| 82 | online: false, |
| 83 | open: argv.open, |
| 84 | startPath: 'examples/index.html', |
| 85 | snippetOptions: { |
| 86 | rule: { |
| 87 | match: /<\/head>/i, |
| 88 | fn: (snippet, match) => snippet.replace('id=', `nonce="browser-sync" id=`) + match |
| 89 | } |
| 90 | }, |
| 91 | }, () => { |
| 92 | console.log('Use Ctrl+C to Quit'); |
| 93 | }); |
| 94 | } |
| 95 | |
| 96 | /** Log to the terminal any watch errors */ |
| 97 | function onError(err) { |