postcss/postcss-cli

Error when project path includes space

SanmayJoshi opened this issue · 5 comments

Summary

PostCSS gives the below error on Windows 11, when the project path contains spaces:

POSTCSS: failed to transform "assets/css/main.css" (text/css): 'C:\Program' is not recognized as an internal or external command,
operable program or batch file.

Project structure:

Project dependency

Hugo Extended

Project path:

C:\Users\Admin\Documents\Project\My Work\Project\Main

package.json

"main": "postcss.config.js"

postcss.config.js

browserslist: [
  "defaults"
],
  module.exports = {
    plugins: {
      "@fullhuman/postcss-purgecss": {
        content: ["layouts/**/*.html"],
        whitelist: ["alert", "close", "collapse", "collapsing", "fade", "modal", "popover", "tooltip", "blockquote"],
        whitelistPatterns: ["/alert$/", "/close$/", "/collapse$/", "/fade$/", "/modal$/", "/popover$/", "/tooltip$/", "/show/", "/alert-.*/", "/close-.*/", "/collapse-.*/", "/fade-.*/", "/modal-.*/", "/popover-.*/", "/tooltip-.*/"],
        whitelistPatternsChildren: ["/alert$/", "/close$/", "/collaps$/", "/fade$/", "/modal$/", "/popover$/", "/tooltip$/", "/alert-.*/", "/close-.*/", "/collapse-.*/", "/fade-.*/", "/modal-.*/", "/popover-.*/", "/tooltip-.*/"]
      },
      autoprefixer: {},
      cssnano: {
        preset: "default"
      }
    },
  }

Steps to reproduce the bug

  1. Install Hugo Extended from https://github.com/gohugoio/hugo/releases (I've installed it via Chocolatey if it makes any difference - choco install hugo-extended)
  2. git clone https://gitlab.com/Softorage/softorage.gitlab.io.git
  3. cd into the cloned repo
  4. npm install
  5. Make sure you are on Windows (I am Win 11), and that the path to the cloned repo contains spaces. Just place the cloned repo in some directory My Work.
  6. hugo serve -e production

What's the actual CLI command you're running?

It is getting called from Hugo. I should've made that clear in the original comment. Adding 'Steps to reproduce the bug' in the original comment.

I'm guessing this is a bug with Hugo, where they're not properly quoting a path on Windows, but would have to know exactly what command Hugo is calling to confirm.

I see that there is an open issue on Hugo's repo gohugoio/hugo#7333.

Yep, that looks like it.