Files
payload/packages/plugin-stripe/src/extendWebpackConfig.ts
Patrik 37b765cce8 fix(plugin-stripe): vite support (#4279)
* chore: updates export of stripe plugin & bumps payload versions

* chore: handles type errors

* chore: adds alias for stripeREST & strepWebhooks

* fixes issues with bundling within demo

* chore: defaults plugin-stripe demo to use vite bundler

* chore: updates pnpm lock file

* chore: removes yarn lock file from plugin-stripe demo

* chore: bumps payload in demo & cleans up demo config

* chore: updates pnpm lock file

---------

Co-authored-by: Jarrod Flesch <jarrodmflesch@gmail.com>
2023-11-28 14:12:18 -05:00

33 lines
1.2 KiB
TypeScript

import type { Config } from 'payload/config'
import type { Configuration as WebpackConfig } from 'webpack'
import path from 'path'
export const extendWebpackConfig =
(config: Config): ((webpackConfig: WebpackConfig) => WebpackConfig) =>
(webpackConfig) => {
const existingWebpackConfig =
typeof config.admin?.webpack === 'function'
? config.admin.webpack(webpackConfig)
: webpackConfig
const mockModulePath = path.resolve(__dirname, './mocks/mockFile.js')
return {
...existingWebpackConfig,
resolve: {
...(existingWebpackConfig.resolve || {}),
alias: {
...(existingWebpackConfig.resolve?.alias ? existingWebpackConfig.resolve.alias : {}),
'@payloadcms/plugin-stripe': path.resolve(__dirname, './admin.js'),
express: mockModulePath,
[path.resolve(__dirname, './hooks/createNewInStripe')]: mockModulePath,
[path.resolve(__dirname, './hooks/deleteFromStripe')]: mockModulePath,
[path.resolve(__dirname, './hooks/syncExistingWithStripe')]: mockModulePath,
[path.resolve(__dirname, './routes/rest')]: mockModulePath,
[path.resolve(__dirname, './routes/webhooks')]: mockModulePath,
},
},
}
}