2.0.0 • Published 6 months ago

@louth/inertia-vue3-unplugin-resolver v2.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

@louth/inertia-vue3-unplugin-resolver

npm version License: MIT

Custom resolver for Vue 3 projects using Inertia.js, enabling automatic imports of Inertia components and composables.

Features

  • Auto-import Inertia.js components (<Link>, <Head>, etc.)
  • Auto-import Inertia.js composables (useForm, usePage, etc.)
  • Zero configuration needed for supported imports
  • Works with unplugin-vue-components and unplugin-auto-import

Installation

# npm
npm install @louth/inertia-vue3-unplugin-resolver --save-dev

# yarn
yarn add @louth/inertia-vue3-unplugin-resolver -D

# pnpm
pnpm add @louth/inertia-vue3-unplugin-resolver -D

Usage

Setup with Vite

// vite.config.js
import { defineConfig } from "vite"
import vue from "@vitejs/plugin-vue"
import Components from "unplugin-vue-components/vite"
import AutoImport from "unplugin-auto-import/vite"
import {
  InertiaVueComponentResolver,
  InertiaVueImports,
} from "@louth/inertia-vue3-unplugin-resolver"

export default defineConfig({
  plugins: [
    vue(),
    Components({
      resolvers: [InertiaVueComponentResolver()],
    }),
    AutoImport({
      imports: [InertiaVueImports],
    }),
  ],
})

Setup with Webpack

// webpack.config.js
const {
  InertiaVueComponentResolver,
  InertiaVueImports,
} = require("@louth/inertia-vue3-unplugin-resolver")
const Components = require("unplugin-vue-components/webpack")
const AutoImport = require("unplugin-auto-import/webpack")

module.exports = {
  // ...
  plugins: [
    Components({
      resolvers: [InertiaVueComponentResolver()],
    }),
    AutoImport({
      imports: [InertiaVueImports],
    }),
  ],
}

Supported Imports

Components (InertiaVueComponentResolver)

The following Inertia.js components can be auto-imported:

  • <Deferred>
  • <Head>
  • <Link>
  • <WhenVisible>

Composables (InertiaVueImports)

The following Inertia.js composables can be auto-imported:

  • useForm
  • usePage
  • useRemember
  • usePrefetch
  • router

Requirements

  • Vue 3
  • Inertia.js v2 (@inertiajs/vue3)

License

MIT

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the project
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request
2.0.0

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago