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

Glob imports do not work with CSS files #6938

Closed
7 tasks done
plmrry opened this issue Feb 15, 2022 · 2 comments · Fixed by #6949
Closed
7 tasks done

Glob imports do not work with CSS files #6938

plmrry opened this issue Feb 15, 2022 · 2 comments · Fixed by #6949

Comments

@plmrry
Copy link

plmrry commented Feb 15, 2022

Describe the bug

I'm not sure if this is a bug or a feature request.

When using import.meta.glob or import.meta.globEager on CSS files, their contents will be empty:

const css = import.meta.globEager("./*.css");
console.log(css);

This generates empty imports:

var one = '';

var __glob_0_0 = /*#__PURE__*/Object.freeze({
  __proto__: null,
  [Symbol.toStringTag]: 'Module',
  'default': one
});

var style = '';

var __glob_0_1 = /*#__PURE__*/Object.freeze({
  __proto__: null,
  [Symbol.toStringTag]: 'Module',
  'default': style
});

var two = '';

var __glob_0_2 = /*#__PURE__*/Object.freeze({
  __proto__: null,
  [Symbol.toStringTag]: 'Module',
  'default': two
});

Reproduction

https://stackblitz.com/edit/vite-css-glob-import?file=ssr-entry.js

System Info

N/A (stackblitz)

Used Package Manager

npm

Logs

No response

Validations

@wommy
Copy link

wommy commented Feb 19, 2022

if you need a solution that works now,

i got css glob import working with postcss-import-ext-glob

@wommy
Copy link

wommy commented Feb 19, 2022

also wondering if you tried passing an array to a function,
ala https://vitejs.dev/guide/assets.html#new-url-url-import-meta-url,
i found my solution before i came across this

@github-actions github-actions bot locked and limited conversation to collaborators Mar 7, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants