Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string #8

Open
simonh1000 opened this issue Nov 17, 2019 · 2 comments

Comments

@simonh1000
Copy link

I'm having trouble with my script. I have

// postcss.config.js
const purgecss = require("@fullhuman/postcss-purgecss")({
    // Specify the paths to all of the template files in your project
    content: ["./themes/losvast20/**/*.ejs"],

    // Include any special characters you're using in this regular expression
    defaultExtractor: content => content.match(/[\w-/:]+(?<!:)/g) || []
});

const nano = require("cssnano")({
    preset: "default"
});

const hash = require("postcss-hash")({
    algorithm: "sha256",
    trim: 20,
    manifest: "./manifest.json"
});

console.log("*******", process.env.NODE_ENV);
process.env.NODE_ENV = "production";

module.exports = {
    from: undefined,
    plugins: [
        require("postcss-nested"),
        require("postcss-color-function"),
        require("tailwindcss"),
        ...(process.env.NODE_ENV === "production" ? [purgecss, nano, hash] : [])
    ]
};

It worked up to the point that I added hashing.

At that point I got an error

ERROR Asset render failed: css/style.css
TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type undefined
    at validateString (internal/validators.js:125:11)
    at Object.dirname (path.js:1260:5)
    at Object.rename (/Users/code/clients/losvast/node_modules/postcss-hash/utils.js:27:19)
    at /Users/code/clients/losvast/node_modules/postcss-hash/index.js:23:32

I'm completely new to postcss and am using it in this project to become more familiar

@kwo
Copy link

kwo commented Sep 18, 2020

I'm having the same issue. Has there been a workaround for this?

@kwisatz
Copy link

kwisatz commented Oct 13, 2023

I'm thinking this might be the same problem as #5.
I also have no luck making this work. Applying the check from #5 will just not create any hashed file for me.

My postcss.config.cjs:

module.exports = {
    plugins: [
      require('postcss-import'),
      require('tailwindcss/nesting'),
      require("stylelint"),
      require('tailwindcss'),
      require('autoprefixer'),
      require('postcss-calc'),
      ...(process.env.JEKYLL_ENV == 'production'
        ? [
          require('cssnano')({ preset: 'default' }),
          // Cannot make this work, see https://github.com/keithamus/postcss-hash/issues/5
          // and https://github.com/keithamus/postcss-hash/issues/8
          // require('postcss-hash')({ algorithm: 'sha256' })
        ]
        : []
      )
    ]
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants