keystone icon indicating copy to clipboard operation
keystone copied to clipboard

Custom next.config.js support for admin-ui

Open ggpwnkthx opened this issue 1 year ago • 8 comments
trafficstars

If /.keystone/admin/../../next.config.js exists, it will get merged into keystone's admin-ui's NextJS config at runtime.

ggpwnkthx avatar Apr 19 '24 16:04 ggpwnkthx

Maybe it would be only write to .keystone/admin/next.config.js if something like config.ui.writeNextConfig !== false? Or similar?

Users can then do whatever they want?

dcousens avatar Jul 17 '24 05:07 dcousens

when #9186 is merged, user should be able to do this

gautamsi avatar Jul 18 '24 02:07 gautamsi

OK, this pull request is superseded by #9186

dcousens avatar Jul 18 '24 04:07 dcousens

Actually @gautamsi, #9186 is a breaking change, maybe we can land this earlier?

dcousens avatar Jul 18 '24 04:07 dcousens

@dcousens do you plan to have any patch/minor release soon? I might make use of that if it comes before end of this month.

gautamsi avatar Jul 18 '24 14:07 gautamsi

Yes, but I don't have time to test this particular pull request before then - can you?

dcousens avatar Jul 25 '24 07:07 dcousens

sure, I can help regularly, do you want to create a label for me which I can keep eye on? I mean create a label like 'pr help wanted' and i can jump in, I usually do not miss any PR from my GitHub notification except occassionally.

Or maybe just assign to me and I can revert back with my finding on specific PR.

gautamsi avatar Jul 25 '24 13:07 gautamsi

I tried testing this, I had to install lodash as dependency which is missing in PR.

I see that there is workaround available to allow using a custom nextjs config. Instead of releasing this I would wait for #9186

this is how to achieve same thing without needing this PR.

  1. extend the base config generated by keystone. you can run keystone dev once to generate one. Copy the content of .keystone/admin/next.config.js to custom next.config.js file (it can be named anything)
  2. extend your config
  3. use following code snippet of keystone.ts to overwrite the generated next.config.js
export default config({
// ....other config
  ui: {
    getAdditionalFiles: [
      () => [{ mode: 'copy', inputPath: path.resolve('next.config.js'), outputPath: 'next.config.js' }]
    ],
  }
})

gautamsi avatar Jul 28 '24 06:07 gautamsi