Skip to content

Commit

Permalink
refactor: browsersync config file watcher
Browse files Browse the repository at this point in the history
  • Loading branch information
cossssmin committed Nov 7, 2023
1 parent c97f5a8 commit 31bd40b
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/commands/serve.js
Expand Up @@ -149,9 +149,12 @@ const serve = async (env = 'local', config = {}) => {

// Watch for changes in config files
browsersync()
.watch('config*.js')
.watch('{maizzle.config*,config*}.{js,cjs}')
.on('change', async file => {
const parsedEnv = path.parse(file).name.split('.')[1] || 'local'
const fileName = path.parse(file).base
const match = fileName.match(/\.?config\.(.+?)\./)

const parsedEnv = match ? match[1] : env || 'local'

Config
.getMerged(parsedEnv)
Expand Down

0 comments on commit 31bd40b

Please sign in to comment.