MCPcopy
hub / github.com/vuejs/vue-loader

github.com/vuejs/vue-loader @v17.4.2 sqlite

repository ↗ · DeepWiki ↗ · release v17.4.2 ↗
80 symbols 208 edges 45 files 0 documented · 0%
README

vue-loader ci

webpack loader for Vue Single-File Components

v17.2.1+ Only Options

  • experimentalInlineMatchResource: boolean: enable Inline matchResource for rule matching for vue-loader.

v16+ Only Options

  • reactivityTransform: boolean: enable Vue Reactivity Transform (SFCs only).

  • ~~refSugar: boolean: removed. use reactivityTransform instead.~~

  • customElement: boolean | RegExp: enable custom elements mode. An SFC loaded in custom elements mode inlines its <style> tags as strings under the component's styles option. When used with defineCustomElement from Vue core, the styles will be injected into the custom element's shadow root.

  • Default is /\.ce\.vue$/

  • Setting to true will process all .vue files in custom element mode.

  • enableTsInTemplate: boolean (16.8+): allow TS expressions in templates when <script> has lang="ts". Defaults to true.

  • When used with ts-loader, due to ts-loader'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 false (and avoid using TS expressions in templates).

  • Alternatively, leave this option on (by default) and use esbuild-loader 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 vue-tsc).

What is Vue Loader?

vue-loader is a loader for webpack that allows you to author Vue components in a format called Single-File Components (SFCs):

<template>


{{ msg }}


</template>

<script>
export default {
  data() {
    return {
      msg: 'Hello world!',
    }
  },
}
</script>

<style>
.example {
  color: red;
}
</style>

There are many cool features provided by vue-loader:

  • Allows using other webpack loaders for each part of a Vue component, for example Sass for <style> and Pug for <template>;
  • Allows custom blocks in a .vue file that can have custom loader chains applied to them;
  • Treat static assets referenced in <style> and <template> 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 vue-loader 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 vue-loader, and is not required knowledge for end users.

vue-loader 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:

  1. vue-loader parses the SFC source code into an SFC Descriptor using @vue/compiler-sfc. It then generates an import for each language block so the actual returned module code looks like this:

```js // code returned from the main loader for 'source.vue'

// import the

Extension points exported contracts — how you extend this code

Props (Interface)
(no doc)
example/types.ts
Props (Interface)
(no doc)
test/fixtures/imported-types.ts
VueLoaderOptions (Interface)
(no doc)
src/index.ts
RuleSetLoader (Interface)
(no doc)
src/pluginWebpack4.ts
RuleSet (Interface)
(no doc)
src/pluginWebpack5.ts
SFCDescriptor (Interface)
(no doc)
src/compiler.ts
Props (Interface)
(no doc)
test/fixtures/imported-types-aliased.ts
CompiledRule (Interface)
(no doc)
src/pluginWebpack5.ts

Core symbols most depended-on inside this repo

mockBundleAndRun
called by 38
test/utils.ts
normalizeNewline
called by 13
test/utils.ts
stringifyRequest
called by 12
src/util.ts
bundle
called by 11
test/utils.ts
genId
called by 8
test/utils.ts
attrsToQuery
called by 4
src/index.ts
createMatcher
called by 4
src/pluginWebpack4.ts
match
called by 4
src/pluginWebpack5.ts

Shape

Function 55
Interface 11
Class 8
Method 6

Languages

TypeScript100%

Modules by API surface

src/pluginWebpack5.ts17 symbols
src/pitcher.ts10 symbols
src/util.ts9 symbols
src/pluginWebpack4.ts7 symbols
src/plugin.ts5 symbols
test/utils.ts4 symbols
src/index.ts4 symbols
src/descriptorCache.ts3 symbols
test/fixtures/App.ts2 symbols
src/resolveScript.ts2 symbols
src/hotReload.ts2 symbols
test/style.spec.ts1 symbols

Dependencies from manifests, versioned

@babel/core7.7.7 · 1×
@babel/preset-env7.11.5 · 1×
@intlify/vue-i18n-loader3.0.0 · 1×
@types/estree0.0.45 · 1×
@types/hash-sum1.0.0 · 1×
@types/jest26.0.13 · 1×
@types/jsdom16.2.13 · 1×
@types/webpack-merge4.1.5 · 1×
babel-loader8.1.0 · 1×
cache-loader4.1.0 · 1×
chalk4.1.0 · 1×

For agents

$ claude mcp add vue-loader \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact