Smoleniuch's avatar

File loader doesnt work as expected in mix.

Hi,

This is my webpack.mix.js config where i use file loader:

  module: {
    rules: [
      //set all files with extension ".hbs" to load via handlebars-loader
      { test: /\.hbs$/, loader: "handlebars-loader" },
      // get url of the image
      {
        test: /\.(png|jpg|gif|svg)$/,
        use: 'file-loader?name=[name].[ext]&outputPath=images/'

      }

    ]

  }

I dont know why but when i import an url path to the image.svg like this: import Image from 'assets/path/to/file/image.svg This creates two files,one in the public/images/image.svg and another with folder public/fonts(i dont know why).The problem is that the imported url is to the file in the fonts folder and when i try to access it gives me an error:

This page contains the following errors:

error on line 1 at column 1: Document is empty
Below is a rendering of the page up to the first error.

The second url inside /public/images folder works great,how to set import url value to valid folder?

0 likes
0 replies

Please or to participate in this conversation.