Webpack4 introduces mp3 file to report error

it is not yet time for packaging. The local introduction has already reported an error in
file path.


I am configured to write file-loader

.
             {
                test: /\.mp3$/,
                use: [{
                  loader: "file-loader",
                  options: {
                    name: "[name].[ext]",
                    outputPath: "img/"
                  }
                }]
              }
Oct.14,2021

{
     test: /\.mp3$/,
     use: [{
       loader: "url-loader",
       options: {
         name: "img/[name].[ext]",
       }
     }]
   }
         
          

tried online methods do not seem to work, the ultimate solution is to directly transfer the MP3 file to the server, and then directly use the absolute path reference on the page, so as to avoid the packaging of webpack, suddenly think of mp3,mp4 these media files, there is no point in webpack packaging ah!


require come in or put it directly in the build folder

Menu