lepikhinb / momentum-trail

MIT License
74 stars 11 forks source link

Possible to use `route` globally w/o importing on each file? #6

Closed flexchar closed 1 year ago

flexchar commented 1 year ago

What a wonderful package! Thank you for it.

Now the question, is it possible to register route as global so that I don't need to import it in every single file? :)

lepikhinb commented 1 year ago

I recommend trying this package.

Here's the example implementation from Mixjobs, the demo project of Advanced Inertia.

import { defineConfig } from "vite"
import autoimport from "unplugin-auto-import/vite"

export default defineConfig({
  plugins: [
    autoimport({
      vueTemplate: true,
      dts: "resources/scripts/types/auto-imports.d.ts",
      imports: [
        "vue",
        "@vueuse/core",
        {
          "momentum-lock": ["can"],
        },
        {
          "momentum-trail": ["route", "current"],
        },
        {
          "@inertiajs/vue3": ["router", "useForm", "usePage", "useRemember"],
        },
      ],
    }),
  ],
})
flexchar commented 1 year ago

Oh this is a great gem, thank you Boris!

PS. put your book on my todo/wish list for the year ;)

EDIT: bought & read; useful resource for newbies.