Values in vue templates don't trigger auto-import
See original GitHub issueIf looking at the template itself isn’t a good idea, perhaps some dev-facing comment directives or config options to set more limited matching for specific use cases could be helpful.
To give an example. I can do the following, but I have to add the variable names to something in the script block for it to work, which kind of defeats the purpose.
AutoImport({
imports: [
'vue',
{
'@mdi/js': Object.keys(await import('@mdi/js')).filter(v=>v.startsWith('mdi')),
}
],
}),
<script setup lang="ts">
// Ideally I wouldn't end up with having to write out import statements with 12+ different variables
// but to get them to auto-import, I've got to do something like this:
const i = {mdiInformationOutline}
// And I can't just do `import * as i from '@mdi/js'` because then it doesn't get tree shook, and I end up with 2MB+ file
</script>
<template>
<main class="px-4 py-10 text-center text-teal-700 dark:text-gray-200">
<div>
<p class="text-4xl">
<v-icon :icon="i.mdiInformationOutline" class="inline-block" />
</p>
</div>
<router-view />
</main>
</template>
Issue Analytics
- State:
- Created 2 years ago
- Comments:10 (2 by maintainers)
Top Results From Across the Web
antfu/unplugin-vue-components: On-demand ... - GitHub
Use components in templates as you would usually do, it will import components on demand, and there is no import and component registration...
Read more >Auto-import VueJs components while coding at SublimeText
I've tried installing ImportJs and AutoImport plugins for Sublime, but for my understanding they only work for .js or .ts files. Is there...
Read more >Vue 3: Support new <script setup> without ref sugar - YouTrack
no auto import when new component is being added through <template>; can't CMD+click open component from <template> when using this new <script setup>....
Read more >Common mistakes to avoid while working with Vue.js
Common mistakes to avoid while working with Vue.js · Include template compiler · Keep property's reactivity · Be careful with SFC exports ·...
Read more >Component Registration - Vue.js
A Vue component needs to be "registered" so that Vue knows where to locate its implementation when it is encountered in a template....
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Shipped in v0.8.0
Thanks.