Answer the question
In order to leave comments, you need to log in
How does webpack loader context work?
Hello, I wrote such a loader
const loaderUtils = require("loader-utils");
module.exports = function loader(content, options, map, meta) {
if (!options) options = loaderUtils.getOptions(this);
if (options.output) {
const name = loaderUtils.interpolateName(this, options.output, options);
this.emitFile(name, content);
}
content = "123loadertext";
this.callback(null, content, map, meta);
};
require(`lite-file-loader?{"output":"sameName.txt"}!..someContentOfLoaderChain`)
const emitFile = require("lite-file-loader");
emitFile(code, { output: "somename.txt" });
Template execution failed: TypeError: this.emitFile is not a function
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question