Is it possible to add plugins to ESBuild for JS in Hugo?

I’m trying to go for an all out Hugo modular theme, without NPM dependencies. Most of the NPM dependencies are done but I’m stuck with dependencies in which index.js imports SCSS styles like cookieconsent/index.js at dev · osano/cookieconsent · GitHub.

I want Hugo to tell ESBuild to use the esbuild-plugin-sass plugin for this purpose, but I couldn’t find any mention in the Hugo docs. Would it be possible to do so, or is there some other way I can approach this?

1 Like

No, currently you can’t add esbuild plugins via configuration. There was a discussion recently that if you set targetPath to a directory then these style imports work. If you set it to a JS file it does not. I tried finding that issue on Github, but it’s either somehow addressed or closed. Maybe that knowledge helps?

2 Likes
2 Likes

I’m curious if there are any updates on this front.

What I’m looking for is a way to use an esbuild plugin that deals with .glsl files but I can’t seem to find any information about using plugins with Hugo js.Build.

Is there any way I can use plugins with js.Build?