-
Notifications
You must be signed in to change notification settings - Fork 920
Description
Version
14.1.0
Reproduction link
https://github.com/miljan-aleksic/vue-loader-chained-issue
Steps to reproduce
Hi guys, I found an issue or at the very least, some awkward behavior when chaining loaders.
I have set up a new webpack project with vue-cli 2x where I have added a custom loader that counts the number of times it has been called and returns that value as .vue valid template, as well as does log it in the terminal.
I did that to show up how the chained loader is called twice or more times depending on the returned string.
Simply clone the repo, install and run npm run dev
.
Note: the custom loader is placed on the custom folder and set on the basic webpack config file.
What is expected?
I would expect the custom loader to be called only once per file and the result to be further processed by vue-loader.
What is actually happening?
The custom loader function gets called several times per file. If it returns <template></template>
it gets called 2 times, if instead returns <template></template><script></script>
it gets called 3 times, and 4 if adding style tags.
Basically, the chained loader is called for each tag.
This can lead to unexpected issues when the chained loader is preprocessing a markdown content for example. I hope we can find the reason behind and fix it.