Vue.js Vite build error <video><source> tag
P粉899950720
P粉899950720 2024-03-25 21:21:53
0
1
370

I'm developing a Vue 3 app and trying to replace a static image with a video but it throws

[vite] Build errored out.
Error: Unexpected character '' (Note that you need plugins to import files that are not JavaScript) at error (/myapp/node_modules/rollup/dist/shared/rollup.js:5275:30)
...

This build (not the image you are using, just for display):

<video class="w-2/3 xs:w-full" controls="controls" name="Video Name">
     <source src="/images/my_image.png">
</video>

This won’t:

<video class="w-2/3 xs:w-full" controls="controls" name="Video Name">
     <source src="/images/my_movie.mov">
</video>

I'm new to Vite and I'd like to understand why it seems to want to import videos from HTML tags.

P粉899950720
P粉899950720

reply all(1)
P粉399585024

As @adain pointed out, the .mov file is not the default list of resource types to be excluded from the transformation pipeline used in the build.

The solution is to configure assetsInclude to add the .mov file to this list: p>

// vite.config.js
import { defineConfig } from 'vite'

export default defineConfig({
  assetsInclude: ['**/*.mov'],
  ⋮
})

Another solution is tobinda literal string: (not required for the above assetsIninclude configuration)


Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!