Skip to content

API > wxt/modules > addImportPreset

Function: addImportPreset()

addImportPreset(wxt, preset): void

Add an Unimport preset (built-in, custom, or auto-scanned), to the project's list of auto-imported utilities.

Some things to note:

  • This function will only de-duplicate built-in preset names. It will not stop you adding duplicate custom or auto-scanned presets.
  • If the project has disabled imports, this function has no effect.

Parameters

wxt: Wxt

The wxt instance provided by the module's setup function.

preset: Preset | "@vue/composition-api" | "@vueuse/core" | "@vueuse/head" | "pinia" | "preact" | "quasar" | "react" | "react-router" | "react-router-dom" | "svelte" | "svelte/animate" | "svelte/easing" | "svelte/motion" | "svelte/store" | "svelte/transition" | "vee-validate" | "vitepress" | "vue-demi" | "vue-i18n" | "vue-router" | "vue-router-composables" | "vue" | "vue/macros" | "vuex" | "vitest" | "uni-app" | "solid-js" | "solid-app-router" | "rxjs" | "date-fns"

The preset to add to the project.

Returns

Example

ts
export default defineWxtModule((wxt) => {
  // Built-in preset:
  addImportPreset(wxt, "vue");
  // Custom preset:
  addImportPreset(wxt, {
    from: "vue",
    imports: ["ref", "reactive", ...],
  });
  // Auto-scanned preset:
  addImportPreset(wxt, { package: "vue" });
});

Source

packages/wxt/src/modules.ts:161


Generated using typedoc-plugin-markdown and TypeDoc