GoogleChromeLabs / postcss-jit-props

A CSS custom property helper based on PostCSS. Supply a pool of variables and this plugin will add them to the stylesheet as they are used.
https://stackblitz.com/edit/jit-open-props?file=postcss.config.js
Apache License 2.0
210 stars 9 forks source link

Error when using Astro #28

Closed mark-looptimize closed 1 year ago

mark-looptimize commented 1 year ago

When using this plugin with Astro I get the following error when running astro build but no such error occurs when running astro dev interestingly.

A PostCSS plugin did not pass the `from` option to `postcss.parse`. 
This may cause imported assets to be incorrectly transformed. 
If you've recently added a PostCSS plugin that raised this warning, please contact the package author to fix the issue.

Through the process of elimination it seemed to be this plugin hence me contacting you as per the message ;-)

For reference here is the postcss.config.cjs file contents:

const openProps = require('open-props');

module.exports = {
  plugins: [
    require('postcss-nesting'),
    require('postcss-custom-media'),
    require('postcss-jit-props')(openProps),
    require('postcss-preset-env')({ stage: 0 })
  ]
};

Here is the package.json contents

{
  "name": "@example/basics",
  "type": "module",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "dev": "astro dev",
    "start": "astro dev",
    "build": "astro build",
    "preview": "astro preview",
    "astro": "astro"
  },
  "dependencies": {
    "astro": "^2.0.5",
    "open-props": "^1.5.5"
  },
  "devDependencies": {
    "postcss-custom-media": "^9.1.1",
    "postcss-jit-props": "^1.0.9",
    "postcss-nesting": "^11.1.0",
    "postcss-preset-env": "^8.0.1"
  }
}
argyleink commented 1 year ago

thanks for reporting!

I'm guessing it has to do with this LOC.

It's not blocking you right? It's just a warning/tip?

mark-looptimize commented 1 year ago

Correct! No block on my end at all :) Thanks for asking though that was super nice