Skip to content

Commit 31a36f6

Browse files
committed
[TASK] update watch process with new chokidar pkg without globs
1 parent 618279a commit 31a36f6

File tree

1 file changed

+19
-4
lines changed

1 file changed

+19
-4
lines changed

lib/compile/watch.js

+19-4
Original file line numberDiff line numberDiff line change
@@ -16,22 +16,37 @@ import { getThemeOptions } from '../utils/options.js'
1616
async function watchVendor () {
1717
try {
1818
const options = getThemeOptions()
19-
chokidar.watch(`${options.vendorSrc}/css/**/*.css`, { ignoreInitial: true, awaitWriteFinish: false }).on('all', (event, path) => {
19+
chokidar.watch(`${options.vendorSrc}/css`, {
20+
ignored: (path, stats) => Boolean(stats?.isFile() && !path.endsWith('.css')),
21+
ignoreInitial: true,
22+
awaitWriteFinish: false
23+
}).on('all', (event, path) => {
2024
console.log(`${chalk.red(event)} ${path}`)
2125
compileCss(true)
2226
})
2327

24-
chokidar.watch(`${options.vendorSrc}/js/**/*.js`, { ignoreInitial: true, awaitWriteFinish: false }).on('all', (event, path) => {
28+
chokidar.watch(`${options.vendorSrc}/js`, {
29+
ignored: (path, stats) => Boolean(stats?.isFile() && !path.endsWith('.js')),
30+
ignoreInitial: true,
31+
awaitWriteFinish: false
32+
}).on('all', (event, path) => {
2533
console.log(`${chalk.red(event)} ${path}`)
2634
compileJs(true)
2735
})
2836

29-
chokidar.watch(`${options.vendorSrc}/scss/**/*.scss`, { ignoreInitial: true }).on('all', (event, path) => {
37+
chokidar.watch(`${options.vendorSrc}/scss`, {
38+
ignored: (path, stats) => Boolean(stats?.isFile() && !path.endsWith('.scss')),
39+
ignoreInitial: true
40+
}).on('all', (event, path) => {
3041
console.log(`${chalk.red(event)} ${path}`)
3142
compileScss(true)
3243
})
3344

34-
chokidar.watch(`${process.cwd()}/${options.themeFolder}/**/fields.js`, { ignoreInitial: true, awaitWriteFinish: false }).on('all', (event, path) => {
45+
chokidar.watch(`${process.cwd()}/${options.themeFolder}`, {
46+
ignored: (path, stats) => Boolean(stats?.isFile() && !path.endsWith('fields.js')),
47+
ignoreInitial: true,
48+
awaitWriteFinish: false
49+
}).on('all', (event, path) => {
3550
console.log(`${chalk.red(event)} ${path}`)
3651
compileFieldsJs(path, true)
3752
})

0 commit comments

Comments
 (0)