Hello,
How do I import a script to a collection to use inside a hook? For example
/* collections > Product.js */
/* Importing someting*/
import { script } from "../utils/scripts";
/* Creating a collection */
const Product = {
slug: 'products',
...
hooks: {
beforeChange: [
async () => { script(); }
]
}
When I build this it builds ok, but when I am trying to access the admin panel it says in the console "webpack_require(...).config is not a function". And when I remove the imports, it works fine.
Any ideas how can I make this work?
Thank you!
Figured it out. Fixed it by changing "require" to "import" in the script.
Star
Discord
online
Get help straight from the Payload team with an Enterprise License.