S
S
shasoft2021-03-27 23:26:28
webpack
shasoft, 2021-03-27 23:26:28

How to tell webpack to use only ONE loader?

I specify my loader However, this loader generates javascript code, which, as I understand it, is then further converted. But webpack thinks that since the extension is .json, it means json is being generated there and trying to do something else with it. it is obvious to use some other bootloader. Question: can I somehow specify that I need to apply only my loader and do nothing else?
import "!./../my-loader!./../../package.json";

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
shasoft, 2021-03-27
@shasoft

I found this hack to change the type from json to javascript

const requiredType = 'javascript/auto';
    const factory = this._compilation.dependencyFactories.get(LoaderDependency);
    this._module.type = requiredType;
    this._module.generator = factory.getGenerator(requiredType);
    this._module.parser = factory.getParser(requiredType);

but the '_' prefix is ​​alarming. Maybe there is a more direct way?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question