Skip to content

Commit

Permalink
[TASK] update watch process with new chokidar pkg without globs
Browse files Browse the repository at this point in the history
  • Loading branch information
dmh committed Oct 11, 2024
1 parent 618279a commit 31a36f6
Showing 1 changed file with 19 additions and 4 deletions.
23 changes: 19 additions & 4 deletions lib/compile/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,37 @@ import { getThemeOptions } from '../utils/options.js'
async function watchVendor () {
try {
const options = getThemeOptions()
chokidar.watch(`${options.vendorSrc}/css/**/*.css`, { ignoreInitial: true, awaitWriteFinish: false }).on('all', (event, path) => {
chokidar.watch(`${options.vendorSrc}/css`, {
ignored: (path, stats) => Boolean(stats?.isFile() && !path.endsWith('.css')),
ignoreInitial: true,
awaitWriteFinish: false
}).on('all', (event, path) => {
console.log(`${chalk.red(event)} ${path}`)
compileCss(true)
})

chokidar.watch(`${options.vendorSrc}/js/**/*.js`, { ignoreInitial: true, awaitWriteFinish: false }).on('all', (event, path) => {
chokidar.watch(`${options.vendorSrc}/js`, {
ignored: (path, stats) => Boolean(stats?.isFile() && !path.endsWith('.js')),
ignoreInitial: true,
awaitWriteFinish: false
}).on('all', (event, path) => {
console.log(`${chalk.red(event)} ${path}`)
compileJs(true)
})

chokidar.watch(`${options.vendorSrc}/scss/**/*.scss`, { ignoreInitial: true }).on('all', (event, path) => {
chokidar.watch(`${options.vendorSrc}/scss`, {
ignored: (path, stats) => Boolean(stats?.isFile() && !path.endsWith('.scss')),
ignoreInitial: true
}).on('all', (event, path) => {
console.log(`${chalk.red(event)} ${path}`)
compileScss(true)
})

chokidar.watch(`${process.cwd()}/${options.themeFolder}/**/fields.js`, { ignoreInitial: true, awaitWriteFinish: false }).on('all', (event, path) => {
chokidar.watch(`${process.cwd()}/${options.themeFolder}`, {
ignored: (path, stats) => Boolean(stats?.isFile() && !path.endsWith('fields.js')),
ignoreInitial: true,
awaitWriteFinish: false
}).on('all', (event, path) => {
console.log(`${chalk.red(event)} ${path}`)
compileFieldsJs(path, true)
})
Expand Down

0 comments on commit 31a36f6

Please sign in to comment.