I'm working with nextjs and webpack and I want to create a webpack plugin so that all…
- User
I'm working with nextjs and webpack and I want to create a webpack plugin so that all imports with the
node:prefix resolve to whatever is after the prefix. e.i.node:dnsresolves todnsThis is what I have so far in my nextjs webpack configs:
codewebpack: (config, { isServer }) => { config.resolve.fallback = { ...config.resolve.fallback, fs: false, }; if (!isServer) { config.resolve.fallback.fs = false; config.resolve.fallback.dns = false; config.resolve.fallback.net = false; config.resolve.fallback.tls = false; config.resolve.fallback.async_hooks = false; config.resolve.fallback.path = false; config.plugins.push( new webpack.NormalModuleReplacementPlugin( /dd-trace/, path.resolve(__dirname, 'mocks/empty.js'), ), ); } else { config.devtool = 'source-map'; } config.module.rules.push({ test: /.*.(js|ts)$/, loader: 'string-replace-loader', options: { search: '/_next/data', replace: `${assetPrefix}/_next/data`, }, }); return config; },
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.