Load video mp4 webpack loader

爱⌒轻易说出口 提交于 2019-12-31 03:26:08

问题


How to use loader for mp4 video format with webpcak 4, I try like this:

       {
            test: /\.mp4$/,
            use: 'file-loader',
            loader: 'file-loader?name=videos/[name].[ext]',
        },

and import like this

import pressButtonAnimated from './images/pressButtonAnimated.mp4'

But it does not work for me, and I get an error You may need an appropriate loader to handle this file type.

But this one is work for me, but I don wanna add in each file

import pressButtonAnimated from '-!file-loader!./images/pressButtonAnimated.mp4'

回答1:


The way how you declare your loader is not right. You are mixing two ways to define loaders.

 {
        test: /\.mp4$/,
        use: 'file-loader?name=videos/[name].[ext]',
 },

Could you try this please.

Link: https://webpack.js.org/concepts/loaders/



来源:https://stackoverflow.com/questions/49943372/load-video-mp4-webpack-loader

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!