I’m quite new to webpack (I’ve been experimenting with it in my spare time for 2-3 months now), but I’ve already written a couple of plugins and some loaders (maybe I’m misusing it since I need to modify how it works out of the box, but anyway…).
I’m currently working on a loader that “combines” different kinds of content (html, css, etc) based on a specific source file (a vue-component file, if you’re curious). After reading blocks of different content from the file, I want my loader to invoke the other loaders defined in the webpack options for each content block, just as if they were separate files of their own, and then continue processing (i.e. combining) the results. Do you follow?
Currently my loader works by tricking webpack to think there are different files, but this is messy and it also doesn’t work with the dev-server, so I want to improve it by directly invoking the other loaders from my loader.
I’ve been digging through the _compiler and _compilation objects available in the loader context, but I feel a little lost. So, assuming my loader is invoked for
path/to/myfile.vue, how can I, from my loader, invoke all the loaders that would be invoked for the hypothetical file
path/to/myfile.less, providing the file contents as a string and getting the resulting script back as a string?