question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Can't use vue plugin with vite

See original GitHub issue

Ziggy version

1.3.5

Laravel version

8.52

Description

Aliasing ziggy to vendor/tightenco/ziggy/dist/vue or vendor/tightenco/ziggy/dist doesn’t allow es module import.

Just posting this in case anyone else has this issue, managed to get it imported using below code. Using the alias didn’t work.

Ziggy call and context

import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m.js';
import { Ziggy } from '../js/ziggy.js';

createApp().use(ZiggyVue, Ziggy)

Ziggy configuration

N/A

Route definition

N/A

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Comments:5

github_iconTop GitHub Comments

5reactions
Spice-Kingcommented, Aug 11, 2021

@atymic You need to toss Ziggy to the optimizer too, like so:

import { defineConfig } from "vite";

export default defineConfig({
  resolve: {
    alias: {
      ziggy: "vendor/tightenco/ziggy/dist/vue",
    },
  },

  optimizeDeps: {
    include: ["ziggy"],
  },
});

Probably worth a note for the docs.

2reactions
bakerkretzmarcommented, Aug 12, 2021

@atymic what if you alias directly to one of the files that uses ES modules? vendor/tightenco/ziggy/dist/vue.es.js or vendor/tightenco/ziggy/dist/vue.m.js?

Read more comments on GitHub >

github_iconTop Results From Across the Web

Can't install @vitejs/plugin-vue - Laracasts
Hi, I've just installed a fresh version of Laravel 9 and wanted to use Vite and Vue, but when I do @vitejs/plugin-vue I've...
Read more >
@vitejs/plugin-vue - npm
Start using @vitejs/plugin-vue in your project by running `npm i ... vite.config.js import vue from '@vitejs/plugin-vue' export default ...
Read more >
[plugin-vue] Can't use custom compiler · Issue #6587 · vitejs/vite
Make sure this is a Vite issue and not a framework-specific issue. For example, if it's a Vue SFC related bug, it should...
Read more >
Adding a plugin to vite - vue.js - Stack Overflow
In reading Vite doc's I see you add plugins via the vite.config.js file instead of using Vue.use() in main.js. So I created one...
Read more >
Unable to use vite plugin referenced type in main vuejs app
src/views/Home.vue:5:32 - error TS6305: Output file 'C:/app/vite_plugins/types.d.ts' has not been built from source ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found