Error when adding a webpack plugin #2190
-
Bug ReportI tried to add the Here is the config I tried: export default buildConfig({
// ...
admin: {
// ...
webpack: (config) => {
const envPlugin = new webpack.EnvironmentPlugin({
HEROKU_BRANCH: 'main',
HEROKU_APP_NAME: 'my-app-name'
});
config.plugins = [envPlugin, ...config.plugins];
return config;
}
},
// ... The app crashed with the following error:
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hey @lynndylanhurley — this is actually because the Webpack plugin you're using relies on some Node-only modules. But - - the Payload config is executed in both Node and in your browser, which is where all of these errors are coming from. You need to use a Webpack alias to tell Webpack to ignore that package for its browser JS, which will allow you to circumvent this issue. See more in our docs here: I will convert this to a discussion but am happy to continue to help! |
Beta Was this translation helpful? Give feedback.
-
Is using fallback ( |
Beta Was this translation helpful? Give feedback.
Hey @lynndylanhurley — this is actually because the Webpack plugin you're using relies on some Node-only modules. But - - the Payload config is executed in both Node and in your browser, which is where all of these errors are coming from. You need to use a Webpack alias to tell Webpack to ignore that package for its browser JS, which will allow you to circumvent this issue.
See more in our docs here:
https://payloadcms.com/docs/admin/webpack#aliasing-server-only-modules
I will convert this to a discussion but am happy to continue to help!