S
S
Svyatoslav Khusamov2018-09-03 14:43:19
React
Svyatoslav Khusamov, 2018-09-03 14:43:19

How to properly use raw-loader for React+WebPack?

I want to import a text file into a variable. And for this I set:
"raw-loader": "^0.5.1",
But none of these options worked:

import cities from './cities.txt';
import cities from '!raw!./cities.txt';
import cities from '!raw./cities.txt';
import cities from 'raw!./cities.txt';

Either an error
Module not found: Can't resolve 'raw' in ...
. Either the path to the file is read, not its contents.
What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question