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

Alias prefixed with # doesn't work with import.meta.glob #17614

Closed
7 tasks done
enkot opened this issue Jul 4, 2024 · 1 comment · Fixed by #17743
Closed
7 tasks done

Alias prefixed with # doesn't work with import.meta.glob #17614

enkot opened this issue Jul 4, 2024 · 1 comment · Fixed by #17743
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)

Comments

@enkot
Copy link

enkot commented Jul 4, 2024

Describe the bug

I try to use import.meta.glob with an alias prefixed with # but it doesn't work:

export default defineConfig({
  resolve: {
    alias: [
      {
        find: '#icons',
        replacement: fileURLToPath(new URL('./assets/icons', import.meta.url)),
      }
    ],
  },
});
const glob = import.meta.glob('#icons/*.svg', { eager: true }); // doesn't work

Prefixed with @ or without prefixes - works fine:

const glob = import.meta.glob('@icons/*.svg', { eager: true }); // works
const glob = import.meta.glob('icons/*.svg', { eager: true }); // works

Reproduction

https://stackblitz.com/edit/vitejs-vite-sx14yb?file=main.js

Steps to reproduce

  1. Run the project.
  2. Open the console.

System Info

System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  Binaries:
    Node: 18.20.3 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 10.2.3 - /usr/local/bin/npm
    pnpm: 8.15.6 - /usr/local/bin/pnpm
  npmPackages:
    vite: ^5.3.2 => 5.3.3

Used Package Manager

npm

Logs

glob #icons {}
glob @icons {/assets/icons/vite.svg: Module}

Validations

Copy link

StackBlitz bot commented Jul 4, 2024

Fix this issue in StackBlitz Codeflow Start a new pull request in StackBlitz Codeflow.

@enkot enkot changed the title Alias prefixed by # doesn't work with import.meta.glob Alias prefixed with # doesn't work with import.meta.glob Jul 4, 2024
@bluwy bluwy added p3-minor-bug An edge case that only affects very specific usage (priority) and removed pending triage labels Jul 23, 2024
@github-actions GitHub Actions bot locked and limited conversation to collaborators Aug 9, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p3-minor-bug An edge case that only affects very specific usage (priority)
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants