Hello there I’m a student struggling with this hugo pipes error. I couldn’t find solutions in this forum.
I was scripting step by step in my Head partial. I have 2 sass files which I concatenate and then convert to css. Everything below works EXCEPT for the last line which returns the following error upon running the hugo command.
hugo v0.92.1-85E2E862+extended windows/amd64 BuildDate=2022-01-27T11:44:41Z VendorInfo=gohugoio
Error: Error building site: POSTCSS: failed to transform “css/global.css” (text/css): Unexpected identifier
Here is my use of pipes
{{- $cssOpts := (dict "targetpath" "css/global.css" "outputStyle" "compressed") -}}
{{- $postOpts := (dict "config" "./postcss.config.js" "targetpath" "css/global.min.css") -}}
{{- $boilerplate := resources.Get "sass/boilerplate.sass" -}}
{{- $template := resources.Get "sass/template.sass" -}}
{{- $globalsass := slice $boilerplate $template | resources.Concat "sass/global.sass" -}}
{{- $style := $globalsass | toCSS $cssOpts -}}
{{- $style = $style | postCSS $postOpts -}}
<link rel="stylesheet" href="{{ $style.Permalink }}" type="text/css">
Where postcss.config.js simply contains:
const autoprefixer = require('autoprefixer');
module.exports = {
plugins: [
autoprefixer()
]
};
Some things I’ve tried:
While initially I had installed hugo-extended via chocolatey on windows and the relevant postcss postcss-cli autoprefixers packages via npm globally.
I encountered the exact same errors using the hugo-extended binary and installing these packages locally, with a configured package json that included devdependancies of postcss postcss-cli and autoprefixer. No combination seems to change the error.
Please help! Any input is greatly appreciated!
Edit: Was running on an old node version, updating node completely changed the error to a solveable one.