choojs / bankai

:station: - friendly web compiler
Apache License 2.0
1.09k stars 102 forks source link

🔦 compiler.assets() seems useless? #491

Closed ZhouHansen closed 6 years ago

ZhouHansen commented 6 years ago

This is a 🔦question.

On bankai build run, fs.copyFile() deals with the assets. On bankai start run, we use compiler.assets() only to check whether the asset file exists, which can be replaced by

send(req, name)
  .on('error', function (err) {
    res.statusCode = 404
    return res.end(err.message)
  })
  .pipe(res)

How about removing the compiler.assets()?

goto-bus-stop commented 6 years ago

compiler.assets() also returns the full file path. I think that's a useful abstraction, then bankai start doesn't have to path.join anything manually.