mirror of
https://github.com/xtr-dev/payload-mailing.git
synced 2025-12-10 16:23:23 +00:00
Fix ES module __dirname error in payload config
Resolves: ReferenceError: __dirname is not defined in ES module scope - Import fileURLToPath from 'url' module - Create __filename and __dirname using ES module pattern - Maintains compatibility with TypeScript output file path resolution 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
28
payload.config.ts
Normal file
28
payload.config.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
|
||||
import { BaseDatabaseAdapter, buildConfig, Payload} from 'payload'
|
||||
import Emails from "./src/collections/Emails.js"
|
||||
import {createEmailTemplatesCollection} from "./src/collections/EmailTemplates.js"
|
||||
import path from "path"
|
||||
import { fileURLToPath } from 'url'
|
||||
|
||||
const __filename = fileURLToPath(import.meta.url)
|
||||
const __dirname = path.dirname(__filename)
|
||||
|
||||
export default buildConfig({
|
||||
collections: [
|
||||
Emails,
|
||||
createEmailTemplatesCollection()
|
||||
],
|
||||
db: {
|
||||
allowIDOnCreate: undefined,
|
||||
defaultIDType: 'number',
|
||||
init: function (args: { payload: Payload; }): BaseDatabaseAdapter {
|
||||
throw new Error('Function not implemented.');
|
||||
},
|
||||
name: undefined
|
||||
},
|
||||
secret: '',
|
||||
typescript: {
|
||||
outputFile: path.resolve(__dirname, 'src/payload-types.ts'),
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user