HUGO

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?

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?

1 Like
1 Like