Is it possible to get the `publicDir` from PostCSS plugins?

I am writing a custom PostCSS plugin to operate on HTML files in the publicDir. Is there a way I can get the path of the publicDir within the plugin JS source?

For example, currently I have to do hugo server -d public and then hardcode the path in my plugin to “public”. I was just wondering if there is a way to get rid of this hardcoded value.

Currently I don’t think so.

This is what we currently pass to all of the Node based tools:

1 Like

But note that I wouldn’t mind if we expanded the above a little to include some of the core config values (but not … everything).

1 Like

Thanks. Having access to this variable would be a huge step forward for me, and I hope for others as well. The use case I’m hoping for is the inclusion of post-build tasks through PostCSS plugins and {{ ... | postCSS | resources.PostProcess }}.

I have one doubt though. Would this work when hugo serves from memory?

No, but there are already certain things that don’t work with that, which is why I always use postprocess in non-server mode only.

1 Like

This topic was automatically closed 2 days after the last reply. New replies are no longer allowed.