英文:
Property 'glob' does not exist on type 'ImportMeta'.ts
问题
上下文
我对Vite和Laravel的经验非常有限,尝试在Laravel中使用Vite进行资源捆绑。
我正在遵循Laravel官方文档的指示:https://laravel.com/docs/9.x/vite#blade-processing-static-assets
由于我使用TypeScript,所以我的入口文件名是:resources/ts/app.ts
当我尝试写入
import.meta.glob([
'../resources/img/..',
]);
我得到了Property 'glob' does not exist on type 'ImportMeta'.ts(2339)
。我理解一旦文件构建完成,我必须使用
<img src="{{ Vite::asset('resources/images/logo.png') }}">
来查看文件,但由于我跳过了更新app.ts
文件。
我能够看到logo.png
为
<img src="https://sensitiveUrl.com/logo.a766f7e6.js"
我正在尝试捆绑静态资源(图片),就像我用css/js做的那样。
英文:
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.
答案1
得分: 4
在项目根目录的tsconfig.json
文件中,添加**"types": ["vite/client"]**到_compilerOptions_。
另外,确保你的vite.config.js文件已正确配置。
英文:
Add "types": ["vite/client"] to compilerOptions in tsconfig.json
in the project root directory.
Also your vite.config.js file should configured correctly.
答案2
得分: 0
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)
英文:
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)
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论