-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathwatch.js
More file actions
33 lines (29 loc) · 1.26 KB
/
watch.js
File metadata and controls
33 lines (29 loc) · 1.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import gulp from 'gulp'
import { paths } from '../gulpfile'
import { scripts, styles, markup, images, manifest } from '.'
import io from 'socket.io'
import fancyLog from 'fancy-log'
import chalk from 'chalk'
export function watch() {
const server = io.listen(process.env.WEBSOCKET_PORT)
let socket
server.on('connection', (newSocket) => { socket = newSocket })
async function triggerFileChange() {
socket.emit('file changed', () => {
fancyLog(chalk.yellow(`Extension reloaded!`))
})
}
gulp.watch('src/**/*.js', gulp.series(scripts, triggerFileChange))
gulp.watch('src/**/*.scss', gulp.series(styles, triggerFileChange))
gulp.watch(paths.manifest, gulp.series(manifest, triggerFileChange))
gulp.watch(paths.images, gulp.series(images, triggerFileChange))
gulp.watch(paths.markup, gulp.series(markup, triggerFileChange))
fancyLog()
fancyLog(chalk.green(`Compiled successfully!`))
fancyLog(chalk.cyan(`To load the unpacked extension and start the ${chalk.bold(`autoreload`)}:`))
fancyLog()
fancyLog(` 1. Go to ${chalk.underline.bold(`chrome://extensions/`)}`)
fancyLog(` 2. Make sure ${chalk.bold(`Developer mode`)} is on`)
fancyLog(` 3. Click ${chalk.bold(`Load unpacked`)} and choose the ${chalk.bold(`build/`)} folder`)
fancyLog()
}