I currently have a postcss.config.js file in the root of my website, and the resource.PostCSS pipe seems to default to using that, which is great. But i really want to use a different config for when i’m developing locally.
Thus i’m using the enviorment variable that hugo automatically sets when using hugo server, to point to a different config using the option config.
Note the different PostCSS config in the two code blocks. I’m trying to just have two configs, one for dev and one for prod. The files are located in the root of the website. Hugo seems to ignore those configs completly, and not using any config for postCSS when i’m doing it like this. If i rename one to be postcss.config.js both steps will use that file - but thats obvious not what i’m trying to achieve.
I’m not sure what i’m doing incorrectly, as i’m following the documentation as best i can.
Is there any repo we could clone so we could try to reproduce this?
BTW I used to have two postcss configs for dev and production, but eventually didn’t want to maintain two separate files with mostly identical content (keep it DRY). I am now checking within the posctss config which environment is used and set options accordingly:
But as you mentioned your self, the two files are looking much the same.
I will try a similar approach, and access the environment variable inside the postcss.config.js file instead.
It has to be named that? Odd, the documentation doesn’t specify it, and their example it’s named something odd as well.
I tried having it in a different folder (in assets) and referenced the path from there. Still, it only used the one named postcss.config.jsthat was in the root. It seems to be ignoring the option dict("config" "assets/postcss-prod.config.js" or dict("config" "postcss-prod.config.js"
Update:
I just tried renaming it postcss.config.js and in the assets folder. That seemed to be working.
Running hugo uses the postcss.config.js in the root, and hugo -e development uses assets/devconfig/postcss.config.js now. Odd, the documentation should be updated to state that it HAS to be named postcss.config.jsIMO.