Skip to content

Is it possible to add a custom script from within a plugin? #9811

Closed Answered by r1tsuu
ametis70 asked this question in Q&A
Discussion options

You must be logged in to vote

For bin scripts this

 (payload: Payload) => Promise<void> 

shouldn't be a thing, since you don't want to introduce your bin script dependencies to user's app bundle and Payload's scripts don't work that way either.

To answer your questions:

  • scriptPath should have an absolute path like /users/user/my-app/node_modules/payload-plugin/script.js. So, for your plugin you should ensure that this path also will exist for those who installed it.
  • Payload instance isn't passed, but the config is, so you can get payload from getPayload({ config }).
    const script: BinScript = await import(pathToFileURL(userBinScript.scrip…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by r1tsuu
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants