vue引入bmp文件报错

报错消息

failed toparse source for import analysis because the content contains invalid js syntax you may need to install appropriate plugins to handle the .bmp file format or is it's an asset , add '**/*.bmp' to 'assetsInclude' in your configuration

报错原因

提示用户需要在 Vite 的配置中将 **/*.bmp 文件路径添加到 assetsInclude 配置选项中。
assetsInclude 是 Vite 配置中的一个选项,用于指定哪些文件应该被视为 “assets” 并且被 Vite 处理。

解决方法

Vite 配置文件,vite.config.js 或 vite.config.ts。
将 ‘**/*.bmp’ 添加到 assetsInclude 数组中。

vite.config.js
在这里插入图片描述

import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'

export default defineConfig(({command})=>{
  return {
    // 这里配置一下
    assetsInclude: [
      '**/*.avi',
    ],
    plugins: [
      vue(),
      vueDevTools(),
    ],
    resolve: {
      alias: {
        '@': fileURLToPath(new URL('./src', import.meta.url))
      }
    },
  }
})
Logo

汇聚全球AI编程工具,助力开发者即刻编程。

更多推荐