ElMassimo / iles

🏝 The joyful site generator
https://iles.pages.dev
MIT License
1.08k stars 32 forks source link

Ship unplugin-auto-import with vue & vue-router presets #243

Open TechAkayy opened 1 year ago

TechAkayy commented 1 year ago

Similar to having unplugin-vue-components, it might be worth including unplugin-auto-import within Iles by default so that APIs can be auto-imported on demand.

unplugin-auto-import is a wrapper on top of https://github.com/unjs/unimport which is used by Nuxt's auto-import as well, and is well-maintained.

Sensible presets for this plugin are: vue & vue-router (another nice alternative would be https://github.com/posva/unplugin-vue-router which is next-gen)

This could be a nice supplement if we decide to turn off reactivityTransform by default.

TechAkayy commented 1 year ago

Also would be good to have this exposed as a config (for eg, autoImportAPIs), so that presets can be extended by users as required. These presets can be those shipped within unplugin-auto-import & those shipped part of libraries.

Something similar to vite's mergeConfig could be used to merge default & overrides.

For eg,

import { defineConfig } from 'iles'
import { VueRouterAutoImports } from 'unplugin-vue-router'

export default defineConfig({
  siteUrl: 'https://iles-docs.netlify.app',
  jsx: 'preact',

  autoImportAPIs: {
      imports: [
        '@vueuse/core',
        VueRouterAutoImports
      ],
  },
})