rsnext/examples/with-why-did-you-render/next.config.js

23 lines
571 B
JavaScript

const path = require('path')
/** @type {import('next').NextConfig} */
const nextConfig = {
webpack(config, { dev, isServer }) {
if (dev && !isServer) {
const originalEntry = config.entry
config.entry = async () => {
const wdrPath = path.resolve(__dirname, './scripts/wdyr.ts')
const entries = await originalEntry()
if (entries['main.js'] && !entries['main.js'].includes(wdrPath)) {
entries['main.js'].push(wdrPath)
}
return entries
}
}
return config
},
}
module.exports = nextConfig