Ignoring server-side by changing the webpack config is working fine in dev, but errors in build.

default discord avatar
Dushyant
2 months ago
2

I'm trying to use opensearch in one of my hooks, and the library does not run in the browser. So I configured webpack to ignore it, following the docs here -



https://payloadcms.com/docs/admin/webpack#aliasing-server-only-modules

Although this works fine in dev (only if I stop using ts-node, albeit with a warning), it doesn't work in production. I get all the errors as if I haven't modified the webpack config at all.



I've tried clearing webpack cache, still doesn't work. What am I doing wrong?



Solved: need to ignore the file with both

.js

and

.ts

extensions. The tutorial mentions

.js

only. Happy to send a PR for the docs if this is actually the recommended solution

  • discord user avatar
    dribbens
    Payload Team
    2 months ago

    That is a good idea for a docs improvement. Aliasing webpack modules is a pain point so anything we can do to make this better is welcomed!

Open the post
Continue the discussion in Discord
Like what we're doing?
Star us on GitHub!

Star

Connect with the Payload Community on Discord

Discord

online

Can't find what you're looking for?

Get help straight from the Payload team with an Enterprise License.