YAML-loader in react returns only file path

Viewed 83

I got the following in my webpack config

{
   test: /\.ya?ml$/,
   use: 'yaml-loader'
}

In one of my TSX files I import a YAML file:

import mydata from './data.yaml'
...

console.log(mydata)

data.yaml content is

text: hello world
text2: hello again

Unfortunately the console output in my browser is /static/media/data.a7c53baa.yaml (the file path where the yaml file is located on the dev server) instead of the parsed content.

I expected a structure similar to {"text":"hello world", "text2":"hello again"} to be printed on the console.

What did I do wrong?

0 Answers
Related