skip to Main Content

Context

I am new to Vite and with very little experience in Laravel, I am trying to use Vite with Laravel for asset bundling.

I’m following instructions from Laravel official documentation : https://laravel.com/docs/9.x/vite#blade-processing-static-assets

Since I’m using TypeScript, So my entry point file name is : resources/ts/app.ts

When I try to write

import.meta.glob([ 
  '../resources/img/..',
]);

I am able to get Property 'glob' does not exist on type 'ImportMeta'.ts(2339). I understand once files are build, I have to use
<img src="{{ Vite::asset('resources/images/logo.png') }}">
to be able to see file, But since I’m skipping to update the app.ts file.

I am able to see logo.png as
<imgsrc="https://sensitiveUrl.com/logo.a766f7e6.js"

I am trying to bundle static assets ( images ), just like how I did with css/js.

2

Answers


  1. Add "types": ["vite/client"] in tsconfig.json in project root directory.

    tsconfig.json
    Also your vite.cofing.js file should configured correctly.

    Login or Signup to reply.
  2. I’m using Vitepress with TypeScript and just fixed this issue by adding "vite": "*" to my devDependencies

    Edit: I also added "vue": "*" in the end (other similar issues)

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search