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

importFrom HTML #33

Closed
silverwind opened this issue Mar 18, 2023 · 4 comments
Closed

importFrom HTML #33

silverwind opened this issue Mar 18, 2023 · 4 comments

Comments

@silverwind
Copy link
Contributor

silverwind commented Mar 18, 2023

I use a pattern where CSS vars are declared in a <style> tag in HTML to ensure they are available in all imported CSS files. Would be nice if this plugin could offer a way to read the vars from HTML:

<html>
  <head>
    <style>
      :root {
        --color-red: #dd2222;
      }
    </style>
  </head>
<html>
@silverwind
Copy link
Contributor Author

I suppose it may be possible if the plugin could just "see" all files that stylelint sees. I lint HTML inline CSS via this stylelint config:

overrides:
  - files: ["**/*.html"]
    customSyntax: postcss-html

So if the plugin can "see" all files in the lint, an option like importFrom may be unnecessary, but I think it may require an architectural change in stylelint for such true multi-file support.

@silverwind
Copy link
Contributor Author

Also see discussion stylelint/stylelint#6361.

@romainmenke
Copy link
Member

I think this is beyond the scope of this rule.

You might get creative with importFrom as you can load JavaScript files here.
Such a JavaScript file might do all the html parsing and expose the results as an object of key/values.

@silverwind
Copy link
Contributor Author

silverwind commented Jan 17, 2024

Luckily I have since moved my vars to .css files now, so I don't need it anymore. It was in HTML only to avoid possible FOUC, but turns out it was never an issue.

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

2 participants