next-remote-refresh icon indicating copy to clipboard operation
next-remote-refresh copied to clipboard

Webpack loader

Open souporserious opened this issue 3 years ago • 0 comments

Ideally, we should only need to set up the plugin and not worry about the hook. I'm thinking we can create a custom loader that injects the hook into the app:

// index.js
config.module.rules.unshift({
  test: /\.(js|jsx|ts|tsx)$/,
  use: [{ loader: path.resolve(__dirname, 'loader') }],
})
// loader.js
module.exports = async function (source) {
  const callback = this.async()
  if (this.resourcePath.includes('_app')) {
    // insert hook here
  }
  return callback(null, source)
}

I don't have much time for this right now so a good first issue if someone wants to take this!

souporserious avatar Jun 27 '21 01:06 souporserious