next-remote-refresh
next-remote-refresh copied to clipboard
Webpack loader
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!