vuejs / vue-loader
📦 Webpack loader for Vue.js components
AI Architecture Analysis
This repository is indexed by RepoMind. By analyzing vuejs/vue-loader in our AI interface, you can instantly generate complete architecture diagrams, visualize control flows, and perform automated security audits across the entire codebase.
Our Agentic Context Augmented Generation (Agentic CAG) engine loads full source files into context on-demand, avoiding the fragmentation of traditional RAG systems. Ask questions about the architecture, dependencies, or specific features to see it in action.
Repository Overview (README excerpt)
Crawler viewvue-loader > webpack loader for Vue Single-File Components • Documentation v17.2.1+ Only Options • : enable Inline matchResource for rule matching for vue-loader. v16+ Only Options • : enable Vue Reactivity Transform (SFCs only). • ~~ : **removed.** use instead.~~ • : enable custom elements mode. An SFC loaded in custom elements mode inlines its tags as strings under the component's option. When used with from Vue core, the styles will be injected into the custom element's shadow root. • Default is • Setting to will process all files in custom element mode. • (16.8+): allow TS expressions in templates when has . Defaults to . • When used with , due to 's cache invalidation behavior, it sometimes prevents the template from being hot-reloaded in isolation, causing the component to reload despite only the template being edited. If this is annoying, you can set this option to (and avoid using TS expressions in templates). • Alternatively, leave this option on (by default) and use to transpile TS instead, which doesn't suffer from this problem (it's also a lot faster). However, do note you will need to rely on TS type checking from other sources (e.g. IDE or ). What is Vue Loader? is a loader for webpack that allows you to author Vue components in a format called Single-File Components (SFCs): There are many cool features provided by : • Allows using other webpack loaders for each part of a Vue component, for example Sass for and Pug for ; • Allows custom blocks in a file that can have custom loader chains applied to them; • Treat static assets referenced in and as module dependencies and handle them with webpack loaders; • Simulate scoped CSS for each component; • State-preserving hot-reloading during development. In a nutshell, the combination of webpack and gives you a modern, flexible and extremely powerful front-end workflow for authoring Vue.js applications. How It Works > The following section is for maintainers and contributors who are interested in the internal implementation details of , and is **not** required knowledge for end users. is not a simple source transform loader. It handles each language blocks inside an SFC with its own dedicated loader chain (you can think of each block as a "virtual module"), and finally assembles the blocks together into the final module. Here's a brief overview of how the whole thing works: • parses the SFC source code into an _SFC Descriptor_ using . It then generates an import for each language block so the actual returned module code looks like this: Notice how the code is importing itself, but with different request queries for each block. • We want the content in block to be treated like files (and if it's , we want to to be treated like files). Same for other language blocks. So we want webpack to apply any configured module rules that matches also to requests that look like . This is what ( ) does: for each module rule in the webpack config, it creates a modified clone that targets corresponding Vue language block requests. Suppose we have configured for all files. That rule will be cloned and applied to Vue SFC blocks as well. Internally to webpack, a request like Will expand to: Notice the is also matched because are applied to files. Similarly, if you have configured + + for files: Will be returned by as: And webpack will expand it to: • When processing the expanded requests, the main will get invoked again. This time though, the loader notices that the request has queries and is targeting a specific block only. So it selects ( ) the inner content of the target block and passes it on to the loaders matched after it. • For the block, this is pretty much it. For and blocks though, a few extra tasks need to be performed: • We need to compile the template using the Vue template compiler; • We need to post-process the CSS in blocks, **after** but **before** . Technically, these are additional loaders ( and ) that need to be injected into the expanded loader chain. It would be very complicated if the end users have to configure this themselves, so also injects a global Pitching Loader ( ) that intercepts Vue and requests and injects the necessary loaders. The final requests look like the following: