S
S
SomeHuman22021-01-01 22:33:36
webpack
SomeHuman2, 2021-01-01 22:33:36

Is it possible to use require on a variable?

Hello, usually the path to the file is specified in require, but is it possible to specify just the content for conversion by loaders instead of the path?
For example, to

require(`file-loader!` "someTestContentHere" ).default

created a file inside which is a line with someTestContentHere?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Aetae, 2021-01-02
@SomeHuman2

No. But you can write your own loader that will do it. It's not hard.
However, it is not clear why the heck is a button accordion for a goat. Just put the real file separately and that's it, than inline horrors to fence. This directly contradicts the idea of ​​modularity, on which all this is built.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question