How can I override Webpack config in a dependency package?

99 views Asked by At

I'm working with keystone-6

which has nextjs as a dependency and I need to override the nextjs Webpack build config from within the keystone project

packages/next/src/build/webpack/config/index.ts <- I think this is the Webpack config in the nextjs dependency (or rather its source). As you can see in the keystone build script, it's included from next/dist/build. But because it's a dependency, its just hanging out in the node_modules. I'm not sure how I can override it as I would if nextjs were included in my package.json directly

    //keystone/packages/core/src/scripts/build.ts
    //...
    import nextBuild from 'next/dist/build';
    //...
    
    export async function build(
      cwd: string,
      { frozen, prisma, ui }: Pick<Flags, 'frozen' | 'prisma' | 'ui'>
    ) {
    //...
      await nextBuild(
        paths.admin,
        undefined,
        undefined,
        undefined,
        undefined,
        undefined,
        undefined,
        undefined,
        'default'
      );
    }

I have tried creating a webpack.config.js and a next.config.js, but both of these files seem to be igored.

0

There are 0 answers