Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 14 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ const { dir, output, replace } = argv

if (argv.map) argv.map = { inline: false }

let configFile
// will be just one config file in the vast majority of cases
const configFiles = new Set()
let argvConfigSet = false

if (argv.env) process.env.NODE_ENV = argv.env
Expand Down Expand Up @@ -127,20 +128,23 @@ try {
},
})

if (configFile) watcher.add(configFile)
if (configFiles.size) watcher.add([...configFiles])

watcher.on('ready', printMessage).on('change', (file) => {
let recompile = []

if (input.includes(file)) recompile.push(file)
// if it's a config file, skip to recompiling everything
if (!configFiles.has(file)) {
if (input.includes(file)) recompile.push(file)

const dependants = depGraph
.dependantsOf(file)
.concat(getAncestorDirs(file).flatMap(depGraph.dependantsOf))
const dependants = depGraph
.dependantsOf(file)
.concat(getAncestorDirs(file).flatMap(depGraph.dependantsOf))

recompile = recompile.concat(
dependants.filter((file) => input.includes(file)),
)
recompile = recompile.concat(
dependants.filter((file) => input.includes(file)),
)
}

if (!recompile.length) recompile = input

Expand Down Expand Up @@ -168,7 +172,7 @@ function rc(ctx, path) {
'Config Error: Can not set from or to options in config file, use CLI arguments instead',
)
}
configFile = rc.file
configFiles.add(rc.file)
return rc
})
.catch((err) => {
Expand Down