Next.js Discord

Discord Forum

Customizing webpack to include another entrypoint in standalone mode

Unanswered
Bohemian Shepherd posted this in #help-forum
Open in Discord
Bohemian ShepherdOP
I have kind of a weird request. I'm trying to make it such that running next build also includes my worker code. That way I can run the same docker container with either node server.js or node worker.js. I'm not entirely sure how to achieve this. I added an entrypoint to the webpack config:
webpack: (config, { isServer, nextRuntime }) => {
    if (isServer && nextRuntime === 'nodejs') {
      const oldEntry = config.entry;

      return {
        ...config,
        async entry(...args) {
          const entries = await oldEntry(...args);
          return {
            ...entries,
            worker: resolve(process.cwd(), './src/worker/index.ts'),
          };
        },
      };
    }
    return config;
  },

And I do see worker.js in the .next/server folder, but it's not included in the standalone output. I also tried:
outputFileTracingIncludes: {
      '/': ['./src/worker/**/*'],
    },

That doesn't seem to include it either

0 Replies